File tree Expand file tree Collapse file tree
3DRadSpace/Engine3DRadSpace/Physics/NVPhysX Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -130,4 +130,33 @@ bool CharacterController::IsGrounded()
130130 }
131131
132132 return false ;
133+ }
134+
135+ float CharacterController::_getMass ()
136+ {
137+ return 0 .0f ;
138+ }
139+
140+ void CharacterController::_setMass (float mass)
141+ {
142+ // Do nothing, character controller doesn't have mass
143+ }
144+
145+ std::optional<float > CharacterController::Intersects (const Math::Ray& r)
146+ {
147+ return std::nullopt ;
148+ }
149+
150+ void CharacterController::UpdateTransform ()
151+ {
152+ if (!_controller) return ;
153+
154+ auto p = _controller->getPosition ();
155+ _position = Vector3 (static_cast <float >(p.x ), static_cast <float >(p.y ), static_cast <float >(p.z ));
156+ }
157+
158+ void CharacterController::UpdateTransform (const Math::Vector3& position, const Math::Quaternion& rotation)
159+ {
160+ if (!_controller) return ;
161+ _controller->setPosition (physx::PxExtendedVec3 (position.X , position.Y , position.Z ));
133162}
Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ namespace Engine3DRadSpace::Physics::NVPhysX
88 class E3DRSP_PHYSICS_OBJ_EXPORT CharacterController : public ICharacterController
99 {
1010 protected:
11+ float _getMass () override ;
12+ void _setMass (float mass) override ;
13+
1114 void _setHeight (float height) override ;
1215 float _getHeight () const noexcept override ;
1316 void _setRadius (float radius) override ;
@@ -19,12 +22,21 @@ namespace Engine3DRadSpace::Physics::NVPhysX
1922
2023 PxUPtr<physx::PxCapsuleController> _controller;
2124 Math::Vector3 _verticalVelocity = Math::Vector3::Zero();
25+
26+ Math::Vector3 _position;
2227 public:
2328 CharacterController (IPhysicsEngine* physics, float height, float radius);
29+
30+ std::optional<float > Intersects (const Math::Ray& r) override ;
31+ void UpdateTransform () override ;
32+ void UpdateTransform (const Math::Vector3& position, const Math::Quaternion& rotation) override ;
33+
2434 void Move (const Math::Vector3& displacement) override ;
2535 void Jump (float height) override ;
2636 bool IsGrounded () override ;
2737
38+ Math::Vector3 GetPosition () const noexcept ;
39+
2840 ~CharacterController () override = default ;
2941 };
3042}
You can’t perform that action at this time.
0 commit comments