Daniele Bartolini 10 лет назад
Родитель
Сommit
3dc4abb587
3 измененных файлов с 8 добавлено и 6 удалено
  1. 4 4
      src/world/physics_world_bullet.cpp
  2. 2 1
      src/world/world.cpp
  3. 2 1
      src/world/world_types.h

+ 4 - 4
src/world/physics_world_bullet.cpp

@@ -811,12 +811,11 @@ public:
 				const btVector3 pos_bt    = tr.getOrigin();
 				const btVector3 pos_bt    = tr.getOrigin();
 				const Quaternion rot      = to_quaternion(rot_bt);
 				const Quaternion rot      = to_quaternion(rot_bt);
 				const Vector3 pos         = to_vector3(pos_bt);
 				const Vector3 pos         = to_vector3(pos_bt);
-				const Matrix4x4 pose      = matrix4x4(rot, pos);
 
 
 				const u32 a_idx = (u32)(uintptr_t)body->getUserPointer();
 				const u32 a_idx = (u32)(uintptr_t)body->getUserPointer();
 				const UnitId unit_id = _actor[a_idx].unit;
 				const UnitId unit_id = _actor[a_idx].unit;
 
 
-				post_transform_event(unit_id, pose);
+				post_transform_event(unit_id, pos, rot);
 			}
 			}
 		}
 		}
 	}
 	}
@@ -940,11 +939,12 @@ private:
 		event_stream::write(_events, EventType::PHYSICS_TRIGGER, ev);
 		event_stream::write(_events, EventType::PHYSICS_TRIGGER, ev);
 	}
 	}
 
 
-	void post_transform_event(UnitId id, const Matrix4x4& world_tm)
+	void post_transform_event(UnitId id, const Vector3& pos, const Quaternion& rot)
 	{
 	{
 		PhysicsTransformEvent ev;
 		PhysicsTransformEvent ev;
 		ev.unit_id = id;
 		ev.unit_id = id;
-		ev.world_tm = world_tm;
+		ev.position = pos;
+		ev.rotation = rot;
 
 
 		event_stream::write(_events, EventType::PHYSICS_TRANSFORM, ev);
 		event_stream::write(_events, EventType::PHYSICS_TRANSFORM, ev);
 	}
 	}

+ 2 - 1
src/world/world.cpp

@@ -252,7 +252,8 @@ void World::update_scene(f32 dt)
 			{
 			{
 				const PhysicsTransformEvent& ptev = *(PhysicsTransformEvent*)ev;
 				const PhysicsTransformEvent& ptev = *(PhysicsTransformEvent*)ev;
 				const TransformInstance ti = _scene_graph->get(ptev.unit_id);
 				const TransformInstance ti = _scene_graph->get(ptev.unit_id);
-				_scene_graph->set_world_pose(ti, ptev.world_tm);
+				const Matrix4x4 pose = matrix4x4(ptev.rotation, ptev.position);
+				_scene_graph->set_world_pose(ti, pose);
 				break;
 				break;
 			}
 			}
 			case EventType::PHYSICS_COLLISION:
 			case EventType::PHYSICS_COLLISION:

+ 2 - 1
src/world/world_types.h

@@ -471,7 +471,8 @@ struct PhysicsTriggerEvent
 struct PhysicsTransformEvent
 struct PhysicsTransformEvent
 {
 {
 	UnitId unit_id;
 	UnitId unit_id;
-	Matrix4x4 world_tm;
+	Vector3 position;    ///< In world-space.
+	Quaternion rotation; ///< In world-space.
 };
 };
 
 
 } // namespace crown
 } // namespace crown