From df30588d74907d15fbdc0f601dffd9b32f33bd3d Mon Sep 17 00:00:00 2001 From: Nou Date: Fri, 15 May 2015 23:16:50 -0700 Subject: [PATCH] What the... Not sure what was going on here with the reverse passing... --- extensions/common/simulation/object.cpp | 25 +++++++++++++------------ extensions/common/simulation/object.hpp | 8 ++++---- extensions/tests/AT_01.txt | 2 +- extensions/vd/base_vehicle.hpp | 2 +- extensions/vd/controller.cpp | 10 +++++----- extensions/vd/vehicle.hpp | 2 +- 6 files changed, 25 insertions(+), 24 deletions(-) diff --git a/extensions/common/simulation/object.cpp b/extensions/common/simulation/object.cpp index 933c24b3f0..295050ed05 100644 --- a/extensions/common/simulation/object.cpp +++ b/extensions/common/simulation/object.cpp @@ -4,15 +4,16 @@ #include "glm\gtc\matrix_transform.hpp" -ace::simulation::vertex::vertex(vertex_table & _table, ace::vector3 _vertex, uint32_t _id) : table(_table), vertex_id(_id) +ace::simulation::vertex::vertex(vertex_table & _table, ace::vector3 _vertex, uint32_t _id, bool reversed) : table(_table), vertex_id(_id) { this->original_vertex = _vertex; this->animated_vertex = _vertex; - //this->original_vertex.z(this->original_vertex.z()*-1); - //this->animated_vertex.z(this->animated_vertex.z()*-1); - //this->original_vertex.x(this->original_vertex.x()*-1); - //this->animated_vertex.x(this->animated_vertex.x()*-1); - + if(reversed) { + this->original_vertex.z(this->original_vertex.z()*-1); + this->animated_vertex.z(this->animated_vertex.z()*-1); + this->original_vertex.x(this->original_vertex.x()*-1); + this->animated_vertex.x(this->animated_vertex.x()*-1); + } } ace::simulation::vertex::~vertex() @@ -75,7 +76,7 @@ void ace::simulation::named_selection::animate(const glm::mat4 &matrix) -ace::simulation::vertex_table::vertex_table(const ace::p3d::vertex_table_p p3d_vertex_table, const ace::p3d::lod_p p3d_lod, const ace::p3d::model_p p3d) : animated(false) +ace::simulation::vertex_table::vertex_table(const ace::p3d::vertex_table_p p3d_vertex_table, const ace::p3d::lod_p p3d_lod, const ace::p3d::model_p p3d, bool reversed) : animated(false) { this->vertices.resize(p3d_vertex_table->points.size); ace::vector3 center_off2 = p3d_lod->min_pos+p3d_lod->max_pos-p3d_lod->autocenter_pos; @@ -83,10 +84,10 @@ ace::simulation::vertex_table::vertex_table(const ace::p3d::vertex_table_p p3d_v for (uint32_t i = 0; i <= p3d_vertex_table->points.size - 1; ++i) { if (p3d->info->autocenter) { ace::vector3 new_vertex = p3d_vertex_table->points[i] + center_off; - this->vertices[i] = std::make_shared(*this, new_vertex, i); + this->vertices[i] = std::make_shared(*this, new_vertex, i, reversed); } else { - this->vertices[i] = std::make_shared(*this, p3d_vertex_table->points[i], i); + this->vertices[i] = std::make_shared(*this, p3d_vertex_table->points[i], i, reversed); } } } @@ -95,10 +96,10 @@ ace::simulation::vertex_table::~vertex_table() { } -ace::simulation::lod::lod(const ace::p3d::lod_p p3d_lod, const ace::p3d::model_p p3d) +ace::simulation::lod::lod(const ace::p3d::lod_p p3d_lod, const ace::p3d::model_p p3d, bool reversed) { this->id = p3d_lod->id; - this->vertices = vertex_table(p3d_lod->vertices, p3d_lod, p3d); + this->vertices = vertex_table(p3d_lod->vertices, p3d_lod, p3d, reversed); this->autocenter_pos = p3d->info->cog_offset;//p3d->info->center_of_gravity + p3d->info->offset_2 + p3d->info->cog_offset; for (ace::p3d::face_p p3d_face : p3d_lod->faces) { @@ -390,7 +391,7 @@ ace::simulation::object::object() ace::simulation::object::object(const ace::p3d::model_p model, bool reverse_ = false) : reversed(reverse_) { for (ace::p3d::lod_p p3d_lod : model->lods) { - lod_p new_lod = std::make_shared(p3d_lod, model); + lod_p new_lod = std::make_shared(p3d_lod, model, reversed); this->lods.push_back(new_lod); this->lods[p3d_lod->id]->type = model->info->resolutions[p3d_lod->id]; } diff --git a/extensions/common/simulation/object.hpp b/extensions/common/simulation/object.hpp index f361d7d343..743d8f2c24 100644 --- a/extensions/common/simulation/object.hpp +++ b/extensions/common/simulation/object.hpp @@ -31,7 +31,7 @@ namespace ace { class vertex_table { public: vertex_table() {}; - vertex_table(const ace::p3d::vertex_table_p, const ace::p3d::lod_p, const ace::p3d::model_p); + vertex_table(const ace::p3d::vertex_table_p, const ace::p3d::lod_p, const ace::p3d::model_p, bool); ~vertex_table(); vertex_p operator[] (const int index) { return vertices[index]; } std::vector vertices; @@ -65,7 +65,7 @@ namespace ace { class vertex { public: - vertex(vertex_table &, ace::vector3, uint32_t); + vertex(vertex_table &, ace::vector3, uint32_t, bool); ~vertex(); ace::vector3 operator * (const float &v) { return animated_vertex * v; } @@ -108,7 +108,7 @@ namespace ace { class lod { public: lod() {}; - lod(const ace::p3d::lod_p, const ace::p3d::model_p); + lod(const ace::p3d::lod_p, const ace::p3d::model_p, bool); ~lod(); uint32_t id; uint32_t type; @@ -202,7 +202,7 @@ namespace ace { class object { public: object(); - object(const ace::p3d::model_p, bool reversed); + object(const ace::p3d::model_p, bool); ~object(); bool reversed; diff --git a/extensions/tests/AT_01.txt b/extensions/tests/AT_01.txt index ca209de8bb..31ceceadf8 100644 --- a/extensions/tests/AT_01.txt +++ b/extensions/tests/AT_01.txt @@ -2,5 +2,5 @@ init: debug_render: register_vehicle:\x\nou\addons\anim_test\anim_test.p3d,0,4050.18;3802.55;5.075 -set_animation_state:0, turret, 0.0, rotation_drum, 0.0, barrel_recoil, -6, barrel_hide, 0 +set_animation_state:0, turret, 1.0, rotation_drum, 0.5, barrel_recoil, -4, barrel_hide, 0 #set_animation_state:0, turret, 0.500 \ No newline at end of file diff --git a/extensions/vd/base_vehicle.hpp b/extensions/vd/base_vehicle.hpp index d85224dcf1..ef588ff9b5 100644 --- a/extensions/vd/base_vehicle.hpp +++ b/extensions/vd/base_vehicle.hpp @@ -20,7 +20,7 @@ namespace ace { class base_vehicle { public: - base_vehicle(uint32_t, ace::simulation::object_p, ace::vector3); + base_vehicle(uint32_t, ace::simulation::object_p, bool, ace::vector3); ~base_vehicle(); bool simulate(); diff --git a/extensions/vd/controller.cpp b/extensions/vd/controller.cpp index 9e6b50739a..19d773cadd 100644 --- a/extensions/vd/controller.cpp +++ b/extensions/vd/controller.cpp @@ -111,7 +111,7 @@ namespace ace { if (ace::model_collection::get().load_model(model_str)) { std::shared_ptr _object = std::make_shared(model_collection::get().models[model_str].model, (static_cast(_args[2]) != 0 ? true : false)); - vehicle_p _vehicle = std::make_shared(static_cast(_args[1]), _object, _args[2]); + vehicle_p _vehicle = std::make_shared(static_cast(_args[1]), _object, false, _args[2]); vehicles[static_cast(_args[1])] = _vehicle; // For results on a valid vehicle registration, we return its animation names for that given vehicle @@ -263,9 +263,9 @@ namespace ace { #endif #ifdef _DEBUG bool controller::_test_raycast(const arguments &_args, std::string & result) { - ace::simulation::object * _object = new ace::simulation::object(model_collection::get().models[0].model); + ace::simulation::object * _object = new ace::simulation::object(model_collection::get().models[0].model, false); std::shared_ptr _object_ptr(_object); - ace::vehicledamage::vehicle _vehicle(12345, _object_ptr, ace::vector3(0,0,0)); + ace::vehicledamage::vehicle _vehicle(12345, _object_ptr, false, ace::vector3(0,0,0)); btVector3 from(1000.0f, 1000.0f, 1000.0f), to(-1000.0f, -1000.0f, -1000.0f); @@ -294,9 +294,9 @@ namespace ace { return true; } bool controller::_test_selection(const arguments &_args, std::string & result) { - ace::simulation::object * _object = new ace::simulation::object(model_collection::get().models[0].model); + ace::simulation::object * _object = new ace::simulation::object(model_collection::get().models[0].model, false); std::shared_ptr _object_ptr(_object); - ace::vehicledamage::vehicle _vehicle(12345, _object_ptr, ace::vector3(0, 0, 0)); + ace::vehicledamage::vehicle _vehicle(12345, _object_ptr, false, ace::vector3(0, 0, 0)); std::vector> _vertices = _vehicle.selection_by_name_vertices(-1, _args[0]); diff --git a/extensions/vd/vehicle.hpp b/extensions/vd/vehicle.hpp index fc1a0b6d34..8c584ba69c 100644 --- a/extensions/vd/vehicle.hpp +++ b/extensions/vd/vehicle.hpp @@ -9,7 +9,7 @@ namespace ace { namespace vehicledamage { class vehicle : public base_vehicle { public: - vehicle(uint32_t id, ace::simulation::object_p object_, ace::vector3 position_) : base_vehicle(id, object_, position_) {} + vehicle(uint32_t id, ace::simulation::object_p object_, bool reversed_, ace::vector3 position_) : base_vehicle(id, object_, reversed_, position_) {} bool hit(gamehit *);