Leviathan  0.8.0.0
Leviathan game engine
Leviathan::PhysicsComponentState Class Reference

State for Physics. More...

#include <CommonStateObjects.h>

+ Inheritance diagram for Leviathan::PhysicsComponentState:

Public Member Functions

DLLEXPORT void Interpolate (Physics &target, PhysicsComponentState &other, float progress)
 Interpolates the target component between this state and the other state. More...
 
- Public Member Functions inherited from Leviathan::ComponentState
 ComponentState (int32_t tick, COMPONENT_TYPE componenttype)
 
virtual ~ComponentState ()
 
virtual DLLEXPORT void CreateUpdatePacket (ComponentState *olderstate, sf::Packet &packet)=0
 Adds update data to a packet. More...
 
virtual DLLEXPORT bool FillMissingData (ComponentState &otherstate)=0
 Copies data to missing values in this state from another state. More...
 
 ComponentState (const ComponentState &other)=delete
 
void operator= (const ComponentState &other)=delete
 

Public Attributes

Member< Float3Position
 
Member< Float4Rotation
 
Member< Float3Velocity
 
Member< Float3Torque
 
- Public Attributes inherited from Leviathan::ComponentState
const int32_t Tick
 The tick this delta state matches. More...
 
const COMPONENT_TYPE ComponentType
 

Additional Inherited Members

- Public Types inherited from Leviathan::ComponentState
template<typename T >
using Member = PotentiallyUpdatedValue< T >
 

Detailed Description

State for Physics.

Definition at line 22 of file CommonStateObjects.h.

Member Function Documentation

◆ Interpolate()

DLLEXPORT void PhysicsComponentState::Interpolate ( Physics target,
PhysicsComponentState other,
float  progress 
)

Interpolates the target component between this state and the other state.

The other state needs to be the more up to date one and progres HAS to be between 0.f and 1.f indicating the progress between the states.

Note
This may not be missing any values, if this is missing values before the call this can be filled directly from the component

Definition at line 64 of file CommonStateObjects.cpp.

66 {
67  Float3 pos = StateHelper::Interpolate(Position, other.Position, progress);
69  Float3 vel = StateHelper::Interpolate(Velocity, other.Velocity, progress);
70  Float3 tor = StateHelper::Interpolate(Torque, other.Torque, progress);
71 
72  target._Position.Members._Position = pos;
73  target._Position.Members._Orientation = rot;
74 
75  target._Position.Marked = true;
76 
77  target.SetVelocity(vel);
78  LOG_WRITE("TODO: shouldn't this be angular momentum? (NewtonBodySetOmega)");
79  target.SetTorque(tor);
80 }
DLLEXPORT void SetTorque(const Float3 &torque)
Overrides this object&#39;s torque in ApplyForceAndTorqueEvent.
Definition: Components.cpp:466
Entity has position and direction it is looking at.
Definition: Components.h:45
#define LOG_WRITE(x)
Definition: Define.h:84
static DLLEXPORT Float4 InterpolateQuoternion(Member< Float4 > &first, Member< Float4 > &second, float progress)
Position & _Position
Physics object requires a position.
Definition: Components.h:553
DLLEXPORT void SetVelocity(const Float3 &velocities)
Overrides this objects velocity in ApplyForceAndTorqueEvent.
Definition: Components.cpp:347
static DLLEXPORT Float3 Interpolate(Member< Float3 > &first, Member< Float3 > &second, float progress)

Member Data Documentation

◆ Position

Member<Float3> Leviathan::PhysicsComponentState::Position

Definition at line 33 of file CommonStateObjects.h.

◆ Rotation

Member<Float4> Leviathan::PhysicsComponentState::Rotation

Definition at line 34 of file CommonStateObjects.h.

◆ Torque

Member<Float3> Leviathan::PhysicsComponentState::Torque

Definition at line 36 of file CommonStateObjects.h.

◆ Velocity

Member<Float3> Leviathan::PhysicsComponentState::Velocity

Definition at line 35 of file CommonStateObjects.h.


The documentation for this class was generated from the following files: