Leviathan  0.8.0.0
Leviathan game engine
Leviathan::SliderConstraint Class Reference

#include <Constraints.h>

+ Inheritance diagram for Leviathan::SliderConstraint:

Public Member Functions

DLLEXPORT SliderConstraint (GameWorld *world, Constraintable &first, Constraintable &second)
 
DLLEXPORT SliderConstraint (GameWorld *world, Constraintable &first, Constraintable &second, int id)
 Variant for forcing id. More...
 
virtual DLLEXPORT ~SliderConstraint ()
 
DLLEXPORT SliderConstraintSetParameters (const Float3 &slidingaxis)
 
DLLEXPORT Float3 GetAxis () const
 Returns the axis along which this joint can move. More...
 
- Public Member Functions inherited from Leviathan::BaseConstraint
DLLEXPORT BaseConstraint (ENTITY_CONSTRAINT_TYPE type, GameWorld *world, Constraintable &first, Constraintable &second)
 
DLLEXPORT BaseConstraint (ENTITY_CONSTRAINT_TYPE type, GameWorld *world, Constraintable &first, Constraintable &second, int id)
 Variant for forcing id. More...
 
virtual DLLEXPORT ~BaseConstraint ()
 
virtual DLLEXPORT bool Init ()
 Actually creates the Newton joint. More...
 
DLLEXPORT void Release ()
 Calls the Newton destroy function. More...
 
DLLEXPORT void Destroy (Constraintable *skipthis=nullptr)
 Call to destroy this constraint. More...
 
DLLEXPORT ENTITY_CONSTRAINT_TYPE GetType () const
 
DLLEXPORT Constraintable & GetFirstEntity () const
 Gets the first object. More...
 
DLLEXPORT Constraintable & GetSecondEntity () const
 Gets the second object. More...
 
DLLEXPORT int GetID () const
 Returns ID. More...
 
- Public Member Functions inherited from Leviathan::ThreadSafeGeneric< MutexType >
DLLEXPORT ThreadSafeGeneric ()
 
DLLEXPORT ~ThreadSafeGeneric ()
 
FORCE_INLINE void VerifyLock (RecursiveLock &guard) const
 
FORCE_INLINE void VerifyLock (Lock &lockit) const
 

Protected Member Functions

virtual bool _CheckParameters () override
 
virtual bool _CreateActualJoint () override
 

Protected Attributes

Float3 Axis
 
- Protected Attributes inherited from Leviathan::BaseConstraint
Constraintable & FirstObject
 
Constraintable & SecondObject
 
int ID
 Server and client matching identifier for deleting constraints. More...
 
GameWorldOwningWorld
 
NewtonJoint * Joint
 
ENTITY_CONSTRAINT_TYPE Type
 Constraint type used by serializers to identify the type. More...
 
- Protected Attributes inherited from Leviathan::ThreadSafeGeneric< MutexType >
MutexType ObjectsLock
 

Detailed Description

Constraint that allows motion along a single axis

Note
The axis has to be normalized otherwise Init fails

Definition at line 110 of file Constraints.h.

Constructor & Destructor Documentation

◆ SliderConstraint() [1/2]

DLLEXPORT SliderConstraint::SliderConstraint ( GameWorld world,
Constraintable &  first,
Constraintable &  second 
)

Definition at line 80 of file Constraints.cpp.

81  :
82  BaseConstraint(ENTITY_CONSTRAINT_TYPE::Slider, world, first, second), Axis(0)
83 {
84 
85 }
DLLEXPORT BaseConstraint(ENTITY_CONSTRAINT_TYPE type, GameWorld *world, Constraintable &first, Constraintable &second)
Definition: Constraints.cpp:9

◆ SliderConstraint() [2/2]

DLLEXPORT SliderConstraint::SliderConstraint ( GameWorld world,
Constraintable &  first,
Constraintable &  second,
int  id 
)

Variant for forcing id.

Used for receiving from network

Definition at line 87 of file Constraints.cpp.

88  :
89  BaseConstraint(ENTITY_CONSTRAINT_TYPE::Slider, world, first, second, id), Axis(0)
90 {
91 
92 }
DLLEXPORT BaseConstraint(ENTITY_CONSTRAINT_TYPE type, GameWorld *world, Constraintable &first, Constraintable &second)
Definition: Constraints.cpp:9

◆ ~SliderConstraint()

DLLEXPORT SliderConstraint::~SliderConstraint ( )
virtual

Definition at line 94 of file Constraints.cpp.

94  {
95 
96 }

Member Function Documentation

◆ _CheckParameters()

bool SliderConstraint::_CheckParameters ( )
overrideprotectedvirtual

Reimplemented from Leviathan::BaseConstraint.

Definition at line 109 of file Constraints.cpp.

109  {
110  if(Axis.IsNormalized())
111  return true;
112 
113  // If the vector is the default one it isn't normalized so the above check will suffice //
114  return false;
115 }
DLLEXPORT bool IsNormalized() const
Definition: Types.h:898

◆ _CreateActualJoint()

bool SliderConstraint::_CreateActualJoint ( )
overrideprotectedvirtual

Reimplemented from Leviathan::BaseConstraint.

Definition at line 117 of file Constraints.cpp.

117  {
118  // We'll just call the Newton create function and that should should be it //
119  Float3 pos(0.f, 0.f, 0.f);
120 
121  // TODO: check if we could add a GetPhysicsBody function to BaseConstraintable
122  try{
123 
124  DEBUG_BREAK;
125  //auto& first = OwningWorld->GetComponent<Physics>(FirstObject.PartOfEntity);
126  //auto& second = OwningWorld->GetComponent<Physics>(SecondObject.PartOfEntity);
127 
128  //Joint = NewtonConstraintCreateSlider(OwningWorld->GetPhysicalWorld()->GetNewtonWorld(),
129  // &pos.X, &Axis.X, first.Body, second.Body);
130 
131  return Joint != NULL;
132 
133  } catch(const NotFound&){
134 
135  Logger::Get()->Error("SliderCOnstraint: trying to create between non-Physics objects");
136  return false;
137  }
138 }
static DLLEXPORT Logger * Get()
Definition: Logger.cpp:106
DLLEXPORT void Error(const std::string &data) override
Definition: Logger.cpp:177

◆ GetAxis()

DLLEXPORT Float3 SliderConstraint::GetAxis ( ) const

Returns the axis along which this joint can move.

Definition at line 105 of file Constraints.cpp.

105  {
106  return Axis;
107 }

◆ SetParameters()

DLLEXPORT SliderConstraint * SliderConstraint::SetParameters ( const Float3 slidingaxis)

Call this before init to set the right parameters

Parameters
slidingaxisIs a normalized axis in global coordinates and defines the axis along which the object can move

Definition at line 98 of file Constraints.cpp.

100 {
101  Axis = slidingaxis;
102  return this;
103 }

Member Data Documentation

◆ Axis

Float3 Leviathan::SliderConstraint::Axis
protected

Definition at line 140 of file Constraints.h.


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