diff options
author | Stijn Buys <ingar@osirion.org> | 2010-11-12 19:50:04 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2010-11-12 19:50:04 +0000 |
commit | e6516fb9999ae47a828e032f0908d2f2ae4b2434 (patch) | |
tree | 80aaed66e95541d93bd56de6fb8cad997e078856 /src/render | |
parent | b460b3193e54b7364bb75ff26ce6f999887e454b (diff) |
enables entity model scaling, Entity::radius() gets precedence over Model::radius(),
corrected bullet motionstate transfer bug in Entity::reset(),
minor cleanups
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/draw.cc | 22 | ||||
-rw-r--r-- | src/render/particles.cc | 8 |
2 files changed, 22 insertions, 8 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc index 3aa9371..c9da6d4 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -327,7 +327,7 @@ void draw_entity_sphere(const core::Entity* entity) void draw_entity_cube(const core::Entity* entity) { - float radius = entity->radius(); + const float radius = entity->radius(); gl::scale(radius, radius, radius); @@ -378,7 +378,7 @@ void draw_entity_cube(const core::Entity* entity) void draw_entity_diamond(const core::Entity* entity) { - float radius = entity->radius() / 2; + const float radius = entity->radius() / 2.0f; /* ---- draw axis lines ---- */ gl::color(entity->color_second()); @@ -792,7 +792,7 @@ void draw_model_bbox(model::Model *model) void draw_model_axis(const core::Entity *entity) { // axis - const float r = entity->radius() * 1.5f; + const float r = entity->model()->radius() * 1.5f; gl::begin(gl::Lines); @@ -832,6 +832,9 @@ void draw_pass_model_fragments() gl::push(); gl::translate(entity->location()); gl::multmatrix(entity->axis()); + + const float modelscale = entity->radius() / entity->model()->radius(); + gl::scale(modelscale, modelscale, modelscale); draw_model_fragments( entity->model(), @@ -851,6 +854,7 @@ void draw_pass_model_fragments() if (r_axis->value()) { draw_model_axis(entity); } + gl::pop(); } } @@ -885,6 +889,8 @@ void draw_pass_model_fx(float elapsed) } if (entity->model() && ext_render(entity)->detailvisible() && power) { + + const float modelscale = entity->radius() / entity->model()->radius(); // disable culling by default gl::disable(GL_CULL_FACE); @@ -939,8 +945,8 @@ void draw_pass_model_fx(float elapsed) } color.a = a; - location.assign(entity->location() + (entity->axis() * light->location())); - light_size = 0.0625f * light->radius(); + location.assign(entity->location() + (entity->axis() * light->location()) * modelscale); + light_size = 0.0625f * light->radius() * modelscale; // track OpenGL state changes if (current_texture != light->texture()) { @@ -1012,8 +1018,8 @@ void draw_pass_model_fx(float elapsed) } color.a = a; - location.assign(entity->location() + (entity->axis() * flare->location())); - light_size = 0.0625f * flare->radius(); + location.assign(entity->location() + (entity->axis() * flare->location()) * modelscale ); + light_size = 0.0625f * flare->radius() * modelscale; // track OpenGL state changes if ((current_cull != flare->cull()) || (current_texture != flare->texture())) { @@ -1110,7 +1116,7 @@ void draw_pass_model_radius() gl::translate(entity->location()); math::Color color = entity->color(); color.a = 0.25f; - draw_sphere(color, entity->model()->radius()); + draw_sphere(color, entity->radius()); gl::pop(); } } diff --git a/src/render/particles.cc b/src/render/particles.cc index 6ffcd35..610c49a 100644 --- a/src/render/particles.cc +++ b/src/render/particles.cc @@ -211,6 +211,14 @@ ParticleSystem::ParticleSystem(ParticleScript *script, core::Entity *entity, mod particlesystem_axis.assign(modelclass->axis()); // particlesystem_cull = particlesystem_modelclass->cull(); } + + + // rescale particle system according to entity radius + if (entity->model() && entity->model()->radius()) { + const float modelscale = entity->radius() / entity->model()->radius(); + particlesystem_location *= modelscale; + particlesystem_radius *= modelscale; + } } ParticleSystem::~ParticleSystem() |