Update Velocity[System/Component] to add CoordSys_Local support (#193)
This commit is contained in:
parent
beed59b94c
commit
fc86d098c3
|
|
@ -19,10 +19,11 @@ namespace Ndk
|
||||||
class NDK_API VelocityComponent : public Component<VelocityComponent>
|
class NDK_API VelocityComponent : public Component<VelocityComponent>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VelocityComponent(const Nz::Vector3f& velocity = Nz::Vector3f::Zero());
|
VelocityComponent(const Nz::Vector3f& velocity = Nz::Vector3f::Zero(), Nz::CoordSys coordSystem = Nz::CoordSys_Global);
|
||||||
~VelocityComponent() = default;
|
~VelocityComponent() = default;
|
||||||
|
|
||||||
Nz::Vector3f linearVelocity;
|
Nz::Vector3f linearVelocity;
|
||||||
|
Nz::CoordSys coordSys;
|
||||||
|
|
||||||
VelocityComponent& operator=(const Nz::Vector3f& vel);
|
VelocityComponent& operator=(const Nz::Vector3f& vel);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,9 @@ namespace Ndk
|
||||||
* \param velocity Linear velocity
|
* \param velocity Linear velocity
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline VelocityComponent::VelocityComponent(const Nz::Vector3f& velocity) :
|
inline VelocityComponent::VelocityComponent(const Nz::Vector3f& velocity, Nz::CoordSys coordSystem) :
|
||||||
linearVelocity(velocity)
|
linearVelocity(velocity),
|
||||||
|
coordSys(coordSystem)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ namespace Ndk
|
||||||
NodeComponent& node = entity->GetComponent<NodeComponent>();
|
NodeComponent& node = entity->GetComponent<NodeComponent>();
|
||||||
const VelocityComponent& velocity = entity->GetComponent<VelocityComponent>();
|
const VelocityComponent& velocity = entity->GetComponent<VelocityComponent>();
|
||||||
|
|
||||||
node.Move(velocity.linearVelocity * elapsedTime, Nz::CoordSys_Global);
|
node.Move(velocity.linearVelocity * elapsedTime, velocity.coordSys);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue