From 82bc4da2b81077ddfc40c1ee37c57033010c9eef Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 12 Nov 2010 21:13:29 +0000 Subject: make the renderer properly respect FragmentGroup::Rotate --- src/model/fragment.cc | 3 +++ src/model/mapfile.cc | 7 +++++-- src/render/draw.cc | 4 ++-- src/render/draw.h | 2 +- src/render/renderext.cc | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/model/fragment.cc b/src/model/fragment.cc index 30e89e0..0e0fd00 100644 --- a/src/model/fragment.cc +++ b/src/model/fragment.cc @@ -64,6 +64,9 @@ FragmentGroup::FragmentGroup() group_type = None; group_scale = 1.0f; group_transform = false; + + group_speed = 0.0f; + group_engine = false; } FragmentGroup::~FragmentGroup() diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc index 2eac688..60fea03 100644 --- a/src/model/mapfile.cc +++ b/src/model/mapfile.cc @@ -817,7 +817,8 @@ void MapFile::load_fragmentgroup(Model *model, const FragmentGroup::Type class_t // default rotation speed 45 degrees per second class_speed = 45.0f; } - //group->set_engine(class_engine); + group->set_speed(class_speed); + group->set_engine(class_engine); } // expand bounding box @@ -1041,7 +1042,8 @@ Model * MapFile::load(std::string const &name) mapfile.class_engine = spawnflag_isset(u, 4); continue; - } else if (mapfile.got_key_float("speed", mapfile.class_speed)) { + } else if (mapfile.got_key_float("speed", s)) { + mapfile.class_speed = s; continue; } else if (mapfile.got_key()) { @@ -1403,6 +1405,7 @@ Model * MapFile::load(std::string const &name) groupdst->set_transform(true); groupdst->set_type(groupsrc->type()); groupdst->set_scale(groupsrc->scale() * tag_submodel->scale()); + groupdst->set_engine(groupsrc->engine()); groupdst->set_speed(groupsrc->speed()); groupdst->set_location(tag_submodel->location() + groupsrc->location() * tag_submodel->scale()); groupdst->set_axis(groupsrc->axis() * tag_submodel->axis()); diff --git a/src/render/draw.cc b/src/render/draw.cc index c9da6d4..780c77e 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -565,7 +565,7 @@ void draw_fragment(const model::Fragment *fragment, bool draw_details) void draw_model_fragments(model::Model *model, const math::Color & color_primary, const math::Color & color_secondary, - const float time, const bool detail, const bool power, const float thrust) + const float enginetime, const bool detail, const bool power, const float thrust) { // default material, lighted and geometry color const model::Material *material = 0; @@ -588,7 +588,7 @@ void draw_model_fragments(model::Model *model, gl::translate(group->location()); if (group->type() == model::FragmentGroup::Rotate) { - float rotation_angle = math::degrees360f(time * group->speed()); + const float rotation_angle = math::degrees360f((group->engine() ? enginetime : core::application()->time()) * group->speed()); gl::rotate(-rotation_angle, group->axis().forward()); } else { gl::multmatrix(group->axis()); diff --git a/src/render/draw.h b/src/render/draw.h index a2b3abc..516da13 100644 --- a/src/render/draw.h +++ b/src/render/draw.h @@ -29,7 +29,7 @@ void draw_sphere(math::Color const & color, float radius); /// draw a model void draw_model_fragments(model::Model *model, const math::Color & color_primary, const math::Color & color_secondary, - const float time, const bool detail, const bool power, const float thrust); + const float enginetime, const bool detail, const bool power, const float thrust); class Stats { diff --git a/src/render/renderext.cc b/src/render/renderext.cc index 197ca6d..29997ca 100644 --- a/src/render/renderext.cc +++ b/src/render/renderext.cc @@ -138,7 +138,7 @@ void RenderExt::frame(float elapsed) if ((controlable->state() == core::Entity::Impulse) || (controlable->state() == core::Entity::ImpulseInitiate)) { state_thrust = 1.0f; } else { - state_thrust = controlable->thrust(); + state_thrust = controlable->thrust(); } state_enginetime += elapsed * state_thrust; -- cgit v1.2.3