Browse Source

make some improvements in Actor

mikymod 12 years ago
parent
commit
9b61b19c3f
2 changed files with 14 additions and 2 deletions
  1. 8 1
      engine/physics/Actor.cpp
  2. 6 1
      engine/physics/Actor.h

+ 8 - 1
engine/physics/Actor.cpp

@@ -78,10 +78,11 @@ namespace crown
 
 //-----------------------------------------------------------------------------
 Actor::Actor(const PhysicsResource* res, const PhysicsConfigResource* config, uint32_t index, PxPhysics* physics, PxCooking* cooking,
-								PxScene* scene, SceneGraph& sg, int32_t node, const Vector3& pos, const Quaternion& rot)
+				PxScene* scene, SceneGraph& sg, int32_t node, Unit* unit, const Vector3& pos, const Quaternion& rot)
 	: m_resource(res)
 	, m_config(config)
 	, m_index(index)
+	, m_unit(unit)
 	, m_scene(scene)
 	, m_scene_graph(sg)
 	, m_node(node)
@@ -430,6 +431,12 @@ StringId32 Actor::name()
 	return a.name;
 }
 
+//-----------------------------------------------------------------------------
+Unit* Actor::unit()
+{
+	return m_unit;
+}
+
 //-----------------------------------------------------------------------------
 void Actor::update(const Matrix4x4& pose)
 {

+ 6 - 1
engine/physics/Actor.h

@@ -60,7 +60,7 @@ struct Actor
 {
 	/// Constructor
 						Actor(const PhysicsResource* res, const PhysicsConfigResource* config, uint32_t index, PxPhysics* physics, PxCooking* cooking,
-								PxScene* scene, SceneGraph& sg, int32_t node, const Vector3& pos, const Quaternion& rot);
+								PxScene* scene, SceneGraph& sg, int32_t node, Unit* unit, const Vector3& pos, const Quaternion& rot);
 	/// Destructor
 						~Actor();
 
@@ -153,6 +153,9 @@ struct Actor
 	/// Returns actor's name
 	StringId32			name();
 
+	/// Returns the unit that owns this actor
+	Unit*				unit();
+
 private:
 
 	void				update(const Matrix4x4& pose);
@@ -165,6 +168,8 @@ public:
 	const PhysicsConfigResource* 	m_config;
 	uint32_t						m_index;
 
+	Unit*							m_unit;
+
 	PxScene*						m_scene;
 	SceneGraph&						m_scene_graph;
 	int32_t							m_node;