Physics Simulation & Visualization Tool 0.1
A C++ physics simulation engine with real-time 3D visualization
Loading...
Searching...
No Matches
Physics::PhysicsBody Class Referenceabstract

#include <PhysicsBody.h>

Inheritance diagram for Physics::PhysicsBody:
[legend]

Public Member Functions

 PhysicsBody ()=delete
 
virtual ~PhysicsBody ()=default
 
virtual void step (float dt, BodyLock lock)=0
 
virtual void recordFrame (float t, BodyLock lock)=0
 
virtual void loadFrame (const ObjectSnapshot &snapshot, BodyLock lock)=0
 
std::unique_lock< std::mutex > lockState () const
 
uint32_t getID () const
 
bool isUnknown (const std::string &key, BodyLock lock) const
 
void setUnknown (const std::string &key, bool active, BodyLock lock)
 
void setForce (const std::string &name, const glm::vec3 &force, BodyLock lock)
 
glm::vec3 getForce (const std::string &name, BodyLock lock) const
 
glm::vec3 getNetForce (BodyLock lock) const
 
std::map< std::string, glm::vec3 > getAllForces (BodyLock lock) const
 
glm::vec3 getPosition (BodyLock lock) const
 
void setPosition (const glm::vec3 &pos, BodyLock lock)
 
glm::vec3 getVelocity (BodyLock lock) const
 
void setVelocity (const glm::vec3 &vel, BodyLock lock)
 
virtual double getMass (BodyLock lock) const
 
virtual void setMass (double newMass, BodyLock lock)
 
virtual ThermalProperties getThermalProperties (BodyLock lock) const
 
virtual void setThermalProperty (const ThermalProperties &newProps, BodyLock lock)
 
float getSurfaceArea () const
 
bool getIsStatic (BodyLock lock) const
 
void setIsStatic (bool newStatic, BodyLock lock)
 
glm::mat4 getWorldTransform (BodyLock lock) const
 
void setWorldTransform (const glm::mat4 &M, BodyLock lock)
 
void setGlobalAccelerationRef (std::atomic< glm::vec3 > &globalAccRef)
 
void clearAllFrames (BodyLock lock)
 
template<typename F >
void withFrames (BodyLock lock, F &&fn) const
 
virtual Bounding::ICollidergetCollider () const
 
virtual bool collidesWith (const PhysicsBody &other) const =0
 
virtual bool collidesWithPointMass (const PointMass &pm) const =0
 
virtual bool collidesWithRigidBody (const RigidBody &rb) const =0
 
virtual bool resolveCollisionWith (float dt, PhysicsBody &other)=0
 
virtual bool resolveCollisionWithPointMass (float dt, PointMass &pm)=0
 
virtual bool resolveCollisionWithRigidBody (float dt, RigidBody &rb)=0
 

Protected Member Functions

 PhysicsBody (uint32_t _id)
 

Protected Attributes

std::mutex stateMutex
 
std::vector< ObjectSnapshotframes
 
float surfaceArea = 1.0f
 

Detailed Description

Definition at line 43 of file PhysicsBody.h.

Constructor & Destructor Documentation

◆ PhysicsBody() [1/2]

Physics::PhysicsBody::PhysicsBody ( )
delete

◆ ~PhysicsBody()

virtual Physics::PhysicsBody::~PhysicsBody ( )
virtualdefault

◆ PhysicsBody() [2/2]

Physics::PhysicsBody::PhysicsBody ( uint32_t  _id)
inlineexplicitprotected

Definition at line 94 of file PhysicsBody.h.

Member Function Documentation

◆ clearAllFrames()

void Physics::PhysicsBody::clearAllFrames ( BodyLock  lock)

Definition at line 159 of file PhysicsBody.cpp.

◆ collidesWith()

virtual bool Physics::PhysicsBody::collidesWith ( const PhysicsBody other) const
pure virtual

Implemented in Physics::PointMass, and Physics::RigidBody.

◆ collidesWithPointMass()

virtual bool Physics::PhysicsBody::collidesWithPointMass ( const PointMass pm) const
pure virtual

Implemented in Physics::PointMass, and Physics::RigidBody.

Here is the caller graph for this function:

◆ collidesWithRigidBody()

virtual bool Physics::PhysicsBody::collidesWithRigidBody ( const RigidBody rb) const
pure virtual

Implemented in Physics::PointMass, and Physics::RigidBody.

Here is the caller graph for this function:

◆ getAllForces()

std::map< std::string, glm::vec3 > Physics::PhysicsBody::getAllForces ( BodyLock  lock) const

Definition at line 59 of file PhysicsBody.cpp.

Here is the caller graph for this function:

◆ getCollider()

virtual Bounding::ICollider * Physics::PhysicsBody::getCollider ( ) const
inlinevirtual

Reimplemented in Physics::RigidBody.

Definition at line 83 of file PhysicsBody.h.

Here is the caller graph for this function:

◆ getForce()

glm::vec3 Physics::PhysicsBody::getForce ( const std::string &  name,
BodyLock  lock 
) const

Definition at line 46 of file PhysicsBody.cpp.

◆ getID()

uint32_t Physics::PhysicsBody::getID ( ) const
inline

Definition at line 54 of file PhysicsBody.h.

◆ getIsStatic()

bool Physics::PhysicsBody::getIsStatic ( BodyLock  lock) const

Definition at line 127 of file PhysicsBody.cpp.

Here is the caller graph for this function:

◆ getMass()

double Physics::PhysicsBody::getMass ( BodyLock  lock) const
virtual

Definition at line 107 of file PhysicsBody.cpp.

Here is the caller graph for this function:

◆ getNetForce()

glm::vec3 Physics::PhysicsBody::getNetForce ( BodyLock  lock) const

Definition at line 67 of file PhysicsBody.cpp.

Here is the caller graph for this function:

◆ getPosition()

glm::vec3 Physics::PhysicsBody::getPosition ( BodyLock  lock) const

Definition at line 75 of file PhysicsBody.cpp.

Here is the caller graph for this function:

◆ getSurfaceArea()

float Physics::PhysicsBody::getSurfaceArea ( ) const
inline

Definition at line 71 of file PhysicsBody.h.

Here is the caller graph for this function:

◆ getThermalProperties()

ThermalProperties Physics::PhysicsBody::getThermalProperties ( BodyLock  lock) const
virtual

Definition at line 198 of file PhysicsBody.cpp.

Here is the caller graph for this function:

◆ getVelocity()

glm::vec3 Physics::PhysicsBody::getVelocity ( BodyLock  lock) const

Definition at line 91 of file PhysicsBody.cpp.

Here is the caller graph for this function:

◆ getWorldTransform()

glm::mat4 Physics::PhysicsBody::getWorldTransform ( BodyLock  lock) const

Definition at line 143 of file PhysicsBody.cpp.

◆ isUnknown()

bool Physics::PhysicsBody::isUnknown ( const std::string &  key,
BodyLock  lock 
) const

Definition at line 8 of file PhysicsBody.cpp.

Here is the caller graph for this function:

◆ loadFrame()

virtual void Physics::PhysicsBody::loadFrame ( const ObjectSnapshot snapshot,
BodyLock  lock 
)
pure virtual

Implemented in Physics::PointMass, and Physics::RigidBody.

◆ lockState()

std::unique_lock< std::mutex > Physics::PhysicsBody::lockState ( ) const
inline

Definition at line 52 of file PhysicsBody.h.

◆ recordFrame()

virtual void Physics::PhysicsBody::recordFrame ( float  t,
BodyLock  lock 
)
pure virtual

Implemented in Physics::PointMass, and Physics::RigidBody.

◆ resolveCollisionWith()

virtual bool Physics::PhysicsBody::resolveCollisionWith ( float  dt,
PhysicsBody other 
)
pure virtual

Implemented in Physics::PointMass, and Physics::RigidBody.

◆ resolveCollisionWithPointMass()

virtual bool Physics::PhysicsBody::resolveCollisionWithPointMass ( float  dt,
PointMass pm 
)
pure virtual

Implemented in Physics::PointMass, and Physics::RigidBody.

Here is the caller graph for this function:

◆ resolveCollisionWithRigidBody()

virtual bool Physics::PhysicsBody::resolveCollisionWithRigidBody ( float  dt,
RigidBody rb 
)
pure virtual

Implemented in Physics::PointMass, and Physics::RigidBody.

Here is the caller graph for this function:

◆ setForce()

void Physics::PhysicsBody::setForce ( const std::string &  name,
const glm::vec3 &  force,
BodyLock  lock 
)

Definition at line 28 of file PhysicsBody.cpp.

Here is the caller graph for this function:

◆ setGlobalAccelerationRef()

void Physics::PhysicsBody::setGlobalAccelerationRef ( std::atomic< glm::vec3 > &  globalAccRef)
inline

Definition at line 77 of file PhysicsBody.h.

◆ setIsStatic()

void Physics::PhysicsBody::setIsStatic ( bool  newStatic,
BodyLock  lock 
)

Definition at line 135 of file PhysicsBody.cpp.

Here is the caller graph for this function:

◆ setMass()

void Physics::PhysicsBody::setMass ( double  newMass,
BodyLock  lock 
)
virtual

Reimplemented in Physics::PointMass.

Definition at line 115 of file PhysicsBody.cpp.

Here is the caller graph for this function:

◆ setPosition()

void Physics::PhysicsBody::setPosition ( const glm::vec3 &  pos,
BodyLock  lock 
)

Definition at line 83 of file PhysicsBody.cpp.

Here is the caller graph for this function:

◆ setThermalProperty()

void Physics::PhysicsBody::setThermalProperty ( const ThermalProperties newProps,
BodyLock  lock 
)
virtual

Reimplemented in Physics::PointMass.

Definition at line 167 of file PhysicsBody.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setUnknown()

void Physics::PhysicsBody::setUnknown ( const std::string &  key,
bool  active,
BodyLock  lock 
)

Definition at line 16 of file PhysicsBody.cpp.

◆ setVelocity()

void Physics::PhysicsBody::setVelocity ( const glm::vec3 &  vel,
BodyLock  lock 
)

Definition at line 99 of file PhysicsBody.cpp.

Here is the caller graph for this function:

◆ setWorldTransform()

void Physics::PhysicsBody::setWorldTransform ( const glm::mat4 &  M,
BodyLock  lock 
)

Definition at line 151 of file PhysicsBody.cpp.

Here is the caller graph for this function:

◆ step()

virtual void Physics::PhysicsBody::step ( float  dt,
BodyLock  lock 
)
pure virtual

Implemented in Physics::PointMass, and Physics::RigidBody.

◆ withFrames()

template<typename F >
void Physics::PhysicsBody::withFrames ( BodyLock  lock,
F &&  fn 
) const

Definition at line 118 of file PhysicsBody.h.

Here is the caller graph for this function:

Field Documentation

◆ frames

std::vector<ObjectSnapshot> Physics::PhysicsBody::frames
protected

Definition at line 97 of file PhysicsBody.h.

◆ stateMutex

std::mutex Physics::PhysicsBody::stateMutex
mutableprotected

Definition at line 96 of file PhysicsBody.h.

◆ surfaceArea

float Physics::PhysicsBody::surfaceArea = 1.0f
protected

Definition at line 98 of file PhysicsBody.h.


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