Kaynağa Gözat

change parameter of Actor::move to Vector3

mikymod 12 yıl önce
ebeveyn
işleme
0aae0fec98
3 değiştirilmiş dosya ile 57 ekleme ve 7 silme
  1. 2 2
      engine/lua/LuaActor.cpp
  2. 3 4
      engine/physics/Actor.cpp
  3. 52 1
      engine/physics/Actor.h

+ 2 - 2
engine/lua/LuaActor.cpp

@@ -101,9 +101,9 @@ CE_EXPORT int actor_move(lua_State* L)
 {
 	LuaStack stack(L);
 	Actor* actor = stack.get_actor(1);
-	Matrix4x4 pose = stack.get_matrix4x4(2);
+	Vector3 pos = stack.get_vector3(2);
 
-	actor->move(pose);
+	actor->move(pos);
 
 	return 0;
 }

+ 3 - 4
engine/physics/Actor.cpp

@@ -281,13 +281,12 @@ void Actor::clear_kinematic()
 }
 
 //-----------------------------------------------------------------------------
-void Actor::move(const Matrix4x4& pose)
+void Actor::move(const Vector3& pos)
 {
 	CE_ASSERT(is_kinematic(), "Cannot call 'move' method for non-kinematic actor");
 
-	Vector3 tmp = pose.translation();
-	PxVec3 pos(tmp.x, tmp.y, tmp.z);
-	static_cast<PxRigidDynamic*>(m_actor)->setKinematicTarget(PxTransform(pos));
+	PxVec3 position(pos.x, pos.y, pos.z);
+	static_cast<PxRigidDynamic*>(m_actor)->setKinematicTarget(PxTransform(position));
 }
 
 //-----------------------------------------------------------------------------

+ 52 - 1
engine/physics/Actor.h

@@ -58,19 +58,35 @@ class SceneGraph;
 
 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);
+	/// Destructor
 						~Actor();
 
+	/// Makes the actor subject to gravity
 	void				enable_gravity();
+
+	/// Makes the actor unsubject to gravity
 	void				disable_gravity();
 
 	void				enable_collision();
 	void				disable_collision();
 
+	/// Makes the actor kinematic (keyframed)
+	/// @note
+	/// Works only for dynamic actors
 	void				set_kinematic();
+
+	/// Makes the actor dynamic
+	/// @note
+	/// Works only for kinematic actors
 	void				clear_kinematic();
-	void				move(const Matrix4x4& pose);
+
+	/// Moves the actor to @a pos
+	/// @note
+	/// Works only for kinematic actors
+	void				move(const Vector3& pos);
 
 	/// Returns whether the actor is static (i.e. immovable).
 	bool				is_static() const;
@@ -81,25 +97,60 @@ struct Actor
 	/// Returns whether the actor is kinematic (i.e. driven by the user).
 	bool				is_kinematic() const;
 
+	/// Returns the rate at which rigid bodies dissipate linear momentum
 	float				linear_damping() const;
+
+	/// Sets the rate at which rigid bodies dissipate linear momentum
 	void				set_linear_damping(float rate);
 
+	/// Returns the rate at which rigid bodies dissipate angular momentum
 	float				angular_damping() const;
+
+	/// Sets the rate at which rigid bodies dissipate angular momentum
 	void				set_angular_damping(float rate);
 
+	/// Returns linear velocity of the actor
+	/// @note
+	/// If actor is sleeping, linear velocity must be 0
 	Vector3				linear_velocity() const;
+
+	/// Sets linear velocity of the actor
+	/// @note
+	/// If actor is sleeping, this will wake it up
 	void				set_linear_velocity(const Vector3& vel);
 
+	/// Returns angular velocity of the actor
+	/// @note
+	/// If actor is sleeping, angular velocity must be 0
 	Vector3				angular_velocity() const;
+
+	/// Sets angular velocity of the actor
+	/// @note
+	/// If actor is sleeping, this will wake it up
 	void				set_angular_velocity(const Vector3& vel);
 
+	/// Applies a force (or impulse) defined in the global coordinate frame, acting at a particular point in global coordinates, to the actor.
+	/// @note
+	/// If the force does not act along the center of mass of the actor, this will also add the corresponding torque.
+	/// Because forces are reset at the end of every timestep, you can maintain a total external force on an object by calling this once every frame.
 	void				add_impulse(const Vector3& impulse);
+
+	/// Applies a force (or impulse) defined in the global coordinate frame, acting at a particular point in local coordinates, to the actor.
+	/// @note
+	/// If the force does not act along the center of mass of the actor, this will also add the corresponding torque.
+	/// Because forces are reset at the end of every timestep, you can maintain a total external force on an object by calling this once every frame. 
 	void				add_impulse_at(const Vector3& impulse, const Vector3& pos);
+
+	/// Applies a force, evaluated by actor's @a mass and @a velocity that will be achieved, to the actor
 	void				push(const Vector3& vel, const float mass);
 
+	/// Returns true if tha actor is sleeping, false otherwise
 	bool				is_sleeping();
+
+	/// Forces the actor to wake up
 	void				wake_up();
 
+	/// Returns actor's name
 	StringId32			name();
 
 private: