Przeglądaj źródła

implement set_local_position and set_local_rotation

mikymod 12 lat temu
rodzic
commit
6f0fc03388
1 zmienionych plików z 21 dodań i 1 usunięć
  1. 21 1
      engine/physics/Shape.cpp

+ 21 - 1
engine/physics/Shape.cpp

@@ -115,10 +115,30 @@ Matrix4x4 Shape::world_pose() const
 	return m;
 }
 
+//-----------------------------------------------------------------------------
+void Shape::set_local_position(const Vector3& p)
+{
+	physx::PxVec3 v(p.x, p.y, p.z);
+
+	physx::PxTransform t(v);
+
+	m_shape->setLocalPose(t);
+}
+
+//-----------------------------------------------------------------------------
+void Shape::set_local_rotation(const Quaternion& r)
+{
+	physx::PxQuat q(r.v.x, r.v.y, r.v.z, r.w);
+
+	physx::PxTransform t(q);
+
+	m_shape->setLocalPose(t);
+}
+
 //-----------------------------------------------------------------------------
 void Shape::set_local_pose(const Matrix4x4& pose)
 {
-	physx::PxMat44 m(const_cast<physx::PxReal*>(pose.to_float_ptr()));
+	physx::PxMat44 m((physx::PxReal*)(pose.to_float_ptr()));
 
 	physx::PxTransform t(m);
 	m_shape->setLocalPose(t);