Leviathan  0.8.0.0
Leviathan game engine
Leviathan::BaseConstraint Class Reference

#include <Constraints.h>

+ Inheritance diagram for Leviathan::BaseConstraint:

Public Member Functions

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 DLLEXPORT bool _CheckParameters ()
 
virtual DLLEXPORT bool _CreateActualJoint ()
 

Protected Attributes

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

Base class for all different types of constraints to inherit

Todo:
Make this actually ThreadSafe

Definition at line 42 of file Constraints.h.

Constructor & Destructor Documentation

◆ BaseConstraint() [1/2]

DLLEXPORT BaseConstraint::BaseConstraint ( ENTITY_CONSTRAINT_TYPE  type,
GameWorld world,
Constraintable &  first,
Constraintable &  second 
)

Definition at line 9 of file Constraints.cpp.

10  :
11  FirstObject(first), SecondObject(second), ID(IDFactory::GetID()),
12  OwningWorld(world), Joint(NULL), Type(type)
13 
14 {
15 
16 }
Constraintable & FirstObject
Definition: Constraints.h:91
static int GetID()
Definition: IDFactory.h:17
ENTITY_CONSTRAINT_TYPE Type
Constraint type used by serializers to identify the type.
Definition: Constraints.h:103
Constraintable & SecondObject
Definition: Constraints.h:92
int ID
Server and client matching identifier for deleting constraints.
Definition: Constraints.h:95

◆ BaseConstraint() [2/2]

DLLEXPORT BaseConstraint::BaseConstraint ( ENTITY_CONSTRAINT_TYPE  type,
GameWorld world,
Constraintable &  first,
Constraintable &  second,
int  id 
)

Variant for forcing id.

Used for receiving from network

Definition at line 18 of file Constraints.cpp.

19  :
20  FirstObject(first), SecondObject(second), ID(id),
21  OwningWorld(world), Joint(NULL), Type(type)
22 {
23 
24 }
Constraintable & FirstObject
Definition: Constraints.h:91
ENTITY_CONSTRAINT_TYPE Type
Constraint type used by serializers to identify the type.
Definition: Constraints.h:103
Constraintable & SecondObject
Definition: Constraints.h:92
int ID
Server and client matching identifier for deleting constraints.
Definition: Constraints.h:95

◆ ~BaseConstraint()

DLLEXPORT BaseConstraint::~BaseConstraint ( )
virtual

Definition at line 26 of file Constraints.cpp.

26  {
27 
28 }

Member Function Documentation

◆ _CheckParameters()

DLLEXPORT bool BaseConstraint::_CheckParameters ( )
protectedvirtual

Reimplemented in Leviathan::SliderConstraint.

Definition at line 62 of file Constraints.cpp.

62  {
63 
64  return false;
65 }

◆ _CreateActualJoint()

DLLEXPORT bool BaseConstraint::_CreateActualJoint ( )
protectedvirtual

Reimplemented in Leviathan::SliderConstraint.

Definition at line 67 of file Constraints.cpp.

67  {
68 
69  return false;
70 }

◆ Destroy()

DLLEXPORT void BaseConstraint::Destroy ( Constraintable *  skipthis = nullptr)

Call to destroy this constraint.

Parameters
skipthisSkips removing from this side, avoid unlinking multiple times from one side when it is being destructed

Definition at line 52 of file Constraints.cpp.

52  {
53 
54  DEBUG_BREAK;
55 }

◆ GetFirstEntity()

DLLEXPORT Constraintable & BaseConstraint::GetFirstEntity ( ) const

Gets the first object.

Definition at line 72 of file Constraints.cpp.

72  {
73  return FirstObject;
74 }
Constraintable & FirstObject
Definition: Constraints.h:91

◆ GetID()

DLLEXPORT int BaseConstraint::GetID ( ) const

Returns ID.

Definition at line 57 of file Constraints.cpp.

57  {
58 
59  return ID;
60 }
int ID
Server and client matching identifier for deleting constraints.
Definition: Constraints.h:95

◆ GetSecondEntity()

DLLEXPORT Constraintable & BaseConstraint::GetSecondEntity ( ) const

Gets the second object.

Definition at line 76 of file Constraints.cpp.

76  {
77  return SecondObject;
78 }
Constraintable & SecondObject
Definition: Constraints.h:92

◆ GetType()

DLLEXPORT ENTITY_CONSTRAINT_TYPE Leviathan::BaseConstraint::GetType ( ) const
inline

Definition at line 72 of file Constraints.h.

72  {
73  return Type;
74  }
ENTITY_CONSTRAINT_TYPE Type
Constraint type used by serializers to identify the type.
Definition: Constraints.h:103

◆ Init()

DLLEXPORT bool BaseConstraint::Init ( )
virtual

Actually creates the Newton joint.

The Constraint won't work without calling this

Precondition
The SetParameters method of the child class is called
Todo:
Allow the error messages to be silenced

Definition at line 30 of file Constraints.cpp.

30  {
31  // We use the virtual functions to make the child class handle this //
32  if(!_CheckParameters()){
33 
34  Logger::Get()->Error("BaseContraint: invalid parameters");
35  return false;
36  }
37 
38  if(!_CreateActualJoint()){
39 
40  Logger::Get()->Error("BaseContraint: failed to create actual joint");
41  return false;
42  }
43 
44  return true;
45 }
virtual DLLEXPORT bool _CheckParameters()
Definition: Constraints.cpp:62
virtual DLLEXPORT bool _CreateActualJoint()
Definition: Constraints.cpp:67
static DLLEXPORT Logger * Get()
Definition: Logger.cpp:106
DLLEXPORT void Error(const std::string &data) override
Definition: Logger.cpp:177

◆ Release()

DLLEXPORT void BaseConstraint::Release ( )

Calls the Newton destroy function.

Definition at line 47 of file Constraints.cpp.

47  {
48 
49  Destroy(nullptr);
50 }
DLLEXPORT void Destroy(Constraintable *skipthis=nullptr)
Call to destroy this constraint.
Definition: Constraints.cpp:52

Member Data Documentation

◆ FirstObject

Constraintable& Leviathan::BaseConstraint::FirstObject
protected

Definition at line 91 of file Constraints.h.

◆ ID

int Leviathan::BaseConstraint::ID
protected

Server and client matching identifier for deleting constraints.

Definition at line 95 of file Constraints.h.

◆ Joint

NewtonJoint* Leviathan::BaseConstraint::Joint
protected

Definition at line 100 of file Constraints.h.

◆ OwningWorld

GameWorld* Leviathan::BaseConstraint::OwningWorld
protected
Note
World is a direct ptr since all joints MUST be destroyed before the world is released

Definition at line 99 of file Constraints.h.

◆ SecondObject

Constraintable& Leviathan::BaseConstraint::SecondObject
protected

Definition at line 92 of file Constraints.h.

◆ Type

ENTITY_CONSTRAINT_TYPE Leviathan::BaseConstraint::Type
protected

Constraint type used by serializers to identify the type.

Definition at line 103 of file Constraints.h.


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