Leviathan  0.8.0.0
Leviathan game engine
Leviathan::PhysicsConstraint Class Reference

This is an instance of a collision body. More...

#include <PhysicsConstraint.h>

+ Inheritance diagram for Leviathan::PhysicsConstraint:

Public Member Functions

DLLEXPORT ~PhysicsConstraint ()
 
DLLEXPORT bool Valid () const
 
DLLEXPORT btTypedConstraint * GetConstraint ()
 
 REFERENCE_COUNTED_PTR_TYPE (PhysicsConstraint)
 
- Public Member Functions inherited from Leviathan::ReferenceCounted
 ReferenceCounted (const ReferenceCounted &other)=delete
 
ReferenceCountedoperator= (const ReferenceCounted &other)=delete
 
FORCE_INLINE void AddRef () const
 
FORCE_INLINE void Release () const
 removes a reference and deletes the object if reference count reaches zero More...
 
FORCE_INLINE void AddRef ()
 
FORCE_INLINE void Release ()
 
int32_t GetRefCount () const
 Returns the reference count. More...
 

Protected Member Functions

DLLEXPORT PhysicsConstraint (btTypedConstraint *constrainttowrap, PhysicsBody *bodya, PhysicsBody *bodyb)
 
DLLEXPORT void DetachResources ()
 This releases all resources held by this. This is called by the PhysicalWorld when this is destroyed or the world wants to be destroyed but there are still external references to this. More...
 
- Protected Member Functions inherited from Leviathan::ReferenceCounted
DLLEXPORT ReferenceCounted ()
 
virtual DLLEXPORT ~ReferenceCounted ()
 

Protected Attributes

friend ReferenceCounted
 

Friends

class PhysicalWorld
 

Additional Inherited Members

- Public Types inherited from Leviathan::ReferenceCounted
using basepointer = boost::intrusive_ptr< ReferenceCounted >
 
using refcountedpointer = boost::intrusive_ptr< ReferenceCounted >
 
- Static Public Member Functions inherited from Leviathan::ReferenceCounted
template<class ActualType >
static boost::intrusive_ptr< ActualType > WrapPtr (ActualType *ptr)
 Creates an intrusive_ptr from raw pointer. More...
 
template<class ActualType , class... Args>
static boost::intrusive_ptr< ActualType > MakeShared (Args &&... args)
 Constructs a new instance and wraps it. More...
 

Detailed Description

This is an instance of a collision body.

Definition at line 18 of file PhysicsConstraint.h.

Constructor & Destructor Documentation

◆ PhysicsConstraint()

DLLEXPORT PhysicsConstraint::PhysicsConstraint ( btTypedConstraint *  constrainttowrap,
PhysicsBody bodya,
PhysicsBody bodyb 
)
protected

Definition at line 9 of file PhysicsConstraint.cpp.

10  :
11  Constraint(constrainttowrap),
12  BodyA(bodya), BodyB(bodyb)
13 {
14  LEVIATHAN_ASSERT(Constraint, "PhysicsConstraint given null constraint");
15 
16  if(BodyA)
17  BodyA->NotifyAttachedConstraint(this);
18 
19  if(BodyB)
20  BodyB->NotifyAttachedConstraint(this);
21 }
DLLEXPORT void NotifyAttachedConstraint(PhysicsConstraint *constraint)
Called by PhysicsConstraint constructor.
Definition: PhysicsBody.cpp:70
#define LEVIATHAN_ASSERT(x, msg)
Definition: Define.h:100

◆ ~PhysicsConstraint()

DLLEXPORT PhysicsConstraint::~PhysicsConstraint ( )

Definition at line 23 of file PhysicsConstraint.cpp.

24 {
25  if(Constraint) {
26  LOG_ERROR("PhysicsConstraint: destroyed before being removed from a world");
28  }
29 }
#define LOG_ERROR(x)
Definition: Define.h:92
DLLEXPORT void DetachResources()
This releases all resources held by this. This is called by the PhysicalWorld when this is destroyed ...

Member Function Documentation

◆ DetachResources()

DLLEXPORT void PhysicsConstraint::DetachResources ( )
protected

This releases all resources held by this. This is called by the PhysicalWorld when this is destroyed or the world wants to be destroyed but there are still external references to this.

Definition at line 31 of file PhysicsConstraint.cpp.

32 {
33  Constraint.reset();
34 
35  if(BodyA)
36  BodyA->NotifyDetachedConstraint(this);
37  BodyA = nullptr;
38 
39  if(BodyB)
40  BodyB->NotifyDetachedConstraint(this);
41  BodyB = nullptr;
42 }
DLLEXPORT void NotifyDetachedConstraint(PhysicsConstraint *constraint)
Called by PhysicsConstraint when detaching resources.
Definition: PhysicsBody.cpp:76

◆ GetConstraint()

DLLEXPORT btTypedConstraint* Leviathan::PhysicsConstraint::GetConstraint ( )
inline

Definition at line 36 of file PhysicsConstraint.h.

37  {
38  return Constraint.get();
39  }

◆ REFERENCE_COUNTED_PTR_TYPE()

Leviathan::PhysicsConstraint::REFERENCE_COUNTED_PTR_TYPE ( PhysicsConstraint  )

◆ Valid()

DLLEXPORT bool Leviathan::PhysicsConstraint::Valid ( ) const
inline

Definition at line 31 of file PhysicsConstraint.h.

32  {
33  return Constraint.operator bool();
34  }

Friends And Related Function Documentation

◆ PhysicalWorld

friend class PhysicalWorld
friend

Definition at line 19 of file PhysicsConstraint.h.

Member Data Documentation

◆ ReferenceCounted

friend Leviathan::PhysicsConstraint::ReferenceCounted
protected

Definition at line 24 of file PhysicsConstraint.h.


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