ToyMaker Game Engine 0.0.2
ToyMaker is a game engine developed and maintained by Zoheb Shujauddin.
Loading...
Searching...
No Matches
types.hpp
1
10
16
17#ifndef TOYMAKERENGINE_PHYSICSTYPES_H
18#define TOYMAKERENGINE_PHYSICSTYPES_H
19
20#include <array>
21#include <string>
22#include <utility>
23
24#include <glm/glm.hpp>
25#include <nlohmann/json.hpp>
26
28
29namespace ToyMaker {
30 struct PhysicsState;
31
47 const ObjectBounds& object,
48 const PhysicsState& physics,
49 const glm::vec3& correctionPoint,
50 const glm::vec3& correctionGradient
51 );
52
67 const ObjectBounds& object,
68 const PhysicsState& physics,
69 const glm::vec3& correctionRotational
70 );
71
79 glm::mat3 computeInertiaRotationalWorld(const glm::vec3& rotationalInertiaLocal, const glm::quat& orientation);
80
89 ObjectBounds object,
90 const PhysicsState& physics,
91 const glm::vec3& impulsePositional,
92 const glm::vec3& impulsePoint
93 );
94
103 ObjectBounds object,
104 const PhysicsState& physics,
105 const glm::vec3& impulseRotational
106 );
107
115 const ObjectBounds& object,
116 PhysicsState physics,
117 const glm::vec3& impulsePositional,
118 const glm::vec3& impulsePoint
119 );
120
127 const ObjectBounds& object,
128 PhysicsState physics,
129 const glm::vec3& impulseRotational
130 );
131
143 using Traits = uint8_t;
144
152 enum Mode: Traits {
159
169
175 };
176
182 static const Traits MaskMode;
183
203
209 static const Traits MaskCollisionResponse;
210
216 inline static std::string getComponentTypeName() { return "PhysicsState"; }
217
225 glm::vec3 mForce { 0.f };
226
235 glm::vec3 mTorque { 0.f };
236
243 glm::vec3 mVelocity { 0.f };
244
251 glm::vec3 mAngularVelocity { 0.f };
252
260 glm::vec3 mRotationalInertiaInverse { 1.f };
261
266 float mMassInverse { 1.f };
267
274
281
290
296 Traits mTraits { static_cast<Traits>(COLLISION_SEPARATE) | static_cast<Traits>(MODE_DYNAMIC) };
297
307 void applyForceGlobal(const glm::vec3& force, const glm::vec3& atPosition, const ObjectBounds& bounds);
308
320 void applyForceLocal(const glm::vec3& force, const glm::vec3& atPosition, const ObjectBounds& bounds);
321
326 inline float getMass() const {
327 if(mMassInverse == 0.f) {
328 return std::numeric_limits<float>::max();
329 }
330 return 1.f / mMassInverse;
331 }
332
337 inline void setMass(float mass) {
338 assert(isNumber(mass) && isPositiveStrict(mass) && "Mass must be a valid positive number");
339 if(mass == std::numeric_limits<float>::max()) {
340 mMassInverse = 0.f;
341 return;
342 }
343 mMassInverse = 1.f / mass;
344 }
345
350 inline glm::vec3 getRotationalInertia() const {
351 return glm::vec3 {
352 mRotationalInertiaInverse.x == 0.f? std::numeric_limits<float>::max(): 1.f / mRotationalInertiaInverse.x,
353 mRotationalInertiaInverse.y == 0.f? std::numeric_limits<float>::max(): 1.f / mRotationalInertiaInverse.y,
354 mRotationalInertiaInverse.z == 0.f? std::numeric_limits<float>::max(): 1.f / mRotationalInertiaInverse.z,
355 };
356 }
357
362 inline void setRotationalInertia(const glm::vec3& rotationalInertia) {
363 assert(
364 isNumber(rotationalInertia) && isPositiveStrict(rotationalInertia)
365 && "Rotational inertia must be valid positive number for each axis"
366 );
367 mRotationalInertiaInverse = glm::vec3 {
368 rotationalInertia.x == std::numeric_limits<float>::max()? 0.f: 1.f / rotationalInertia.x,
369 rotationalInertia.y == std::numeric_limits<float>::max()? 0.f: 1.f / rotationalInertia.y,
370 rotationalInertia.z == std::numeric_limits<float>::max()? 0.f: 1.f / rotationalInertia.z,
371 };
372 }
373
378 inline void setCoefficientRestitution(float newCoefficient) {
379 assert(
380 isNonNegative(newCoefficient) && newCoefficient <= 1.f
381 && "Restitution coefficient must be non negative and cannot exceed 1"
382 );
383 mCoefficientRestitution = newCoefficient;
384 }
385
390 inline Mode getMode() const {
391 switch(mTraits&MaskMode) {
392 case MODE_DYNAMIC:
393 return MODE_DYNAMIC;
394 case MODE_KINEMATIC:
395 return MODE_KINEMATIC;
396 case MODE_STATIC:
397 return MODE_STATIC;
398 default:
399 return MODE_STATIC;
400 assert(false && "Unrecognized physics type specified");
401 }
402 }
403
408 inline void setMode(Mode mode) {
409 switch(mode&MaskMode) {
410 case MODE_DYNAMIC:
411 case MODE_KINEMATIC:
412 case MODE_STATIC:
413 mTraits = (mTraits&(~MaskMode)) | mode;
414 return;
415 default:
416 assert(false && "Unrecognized physics type specified");
417 }
418 }
419
429 inline bool separatesOnCollision() const {
430 return mTraits&static_cast<Traits>(COLLISION_SEPARATE);
431 }
432
442 inline bool signalsOnCollision() const {
443 return mTraits&static_cast<Traits>(COLLISION_SIGNAL);
444 }
445
451 mTraits |= response;
452 }
453
459 mTraits &= ~response;
460 }
461 };
462
463 inline const PhysicsState::Traits PhysicsState::MaskMode { 0x3 };
464 inline const PhysicsState::Traits PhysicsState::MaskCollisionResponse { 0xC };
465
476 private:
486 float mCompliance { 0.f };
487
488 protected:
493 BaseConstraint(float compliance) { setCompliance(compliance); }
494
495 public:
496 using ParticipantID = std::size_t;
497 using ParticipantTable = std::unordered_map<
498 ParticipantID,
499 std::pair<
500 std::reference_wrapper<ObjectBounds>,
501 std::reference_wrapper<PhysicsState>
502 >
503 >;
504
509 float getCompliance() const;
510
519 const ParticipantTable& states,
520 float substepSeconds
521 ) {}
522
531 const ParticipantTable& states,
532 float substepSeconds
533 ) {}
534
540 virtual void resetLagrange() {}
541
546 void setCompliance(float newCompliance);
547
548 virtual ~BaseConstraint() {};
549 };
550
551
557 template<uint8_t LagrangeCount>
559 private:
565 template<uint8_t... ints>
566 void resetLagrange(std::integer_sequence<uint8_t, ints...> index);
567
577 std::array<float, LagrangeCount> mLagrangeMultipliers { 0.f };
578
583 std::array<float, LagrangeCount> mLagrangeDeltas { 0.f };
584
585 protected:
590 Constraint(float compliance): BaseConstraint { compliance } {}
591
592 public:
597 void applyLagrangeDelta(float delta, uint8_t index);
598
603 const std::array<float, LagrangeCount>& getLagrange() const;
604
609 const std::array<float, LagrangeCount>& getLagrangeDelta() const;
610
614 void resetLagrange() override;
615 };
616
624 template <typename TParameter, uint8_t LagrangeCount>
625 class ParametrizedConstraint: public Constraint<LagrangeCount> {
626 private:
633 std::unordered_map<BaseConstraint::ParticipantID, TParameter> mParameters {};
634
635 protected:
640 ParametrizedConstraint(float compliance): Constraint<LagrangeCount> { compliance } {}
641
642 public:
647 void setParameter(BaseConstraint::ParticipantID participant, const TParameter& parameter);
648
653 inline TParameter getParameter(BaseConstraint::ParticipantID participant) const {
654 return mParameters.at(participant);
655 }
656
661 void removeParameter(BaseConstraint::ParticipantID participant);
662
667 const std::unordered_map<BaseConstraint::ParticipantID, TParameter>& getParameters() const;
668 };
669
677 struct CollisionConstraint: public Constraint<2> {
678 public:
684 bool mCollided { false };
685
690 glm::vec3 mLastPointContactA { 0.f };
691
696 glm::vec3 mCurrentPointContactA { 0.f };
697
702 glm::vec3 mRelativePointContactA { 0.f };
703
708 glm::vec3 mLastPointContactB { 0.f };
709
714 glm::vec3 mCurrentPointContactB { 0.f };
715
720 glm::vec3 mRelativePointContactB { 0.f };
721
727 glm::vec3 mContactNormal { 0.f };
728
734 float mCollisionVelocity { 0.f };
735
741 float mPenetrationDepth { 0.f };
742
748
754 const Collision& collision,
755 const PhysicsState& physicsA,
756 const ObjectBounds& boundsA,
757 const ObjectBounds& boundsAPrev,
758 const PhysicsState& physicsB,
759 const ObjectBounds& boundsB,
760 const ObjectBounds& boundsBPrev
761 );
762
769 const PhysicsState& physicsA,
770 const ObjectBounds& boundsA,
771 const PhysicsState& physicsB,
772 const ObjectBounds& boundsB
773 );
774
780 const ParticipantTable& states,
781 float substepSeconds
782 ) override;
783
789 const ParticipantTable& states,
790 float substepSeconds
791 ) override;
792 };
793
794 NLOHMANN_JSON_SERIALIZE_ENUM(PhysicsState::Mode, {
795 { PhysicsState::MODE_DYNAMIC, "dynamic" },
796 { PhysicsState::MODE_KINEMATIC, "kinematic" },
797 { PhysicsState::MODE_STATIC, "static" },
798 });
799
800 NLOHMANN_JSON_SERIALIZE_ENUM(PhysicsState::CollisionResponse, {
801 { PhysicsState::COLLISION_SEPARATE, "separate" },
802 { PhysicsState::COLLISION_SIGNAL, "signal" },
803 });
804
805 inline void from_json(
806 const nlohmann::json& json,
807 PhysicsState& physics
808 ) {
809 assert(json.at("type") == PhysicsState::getComponentTypeName() && "Incorrect type property for an physics property component");
810 physics = {};
811
812 float mass;
813 if(json.at("mass").is_string() && json.at("mass") == "infinity") {
814 mass = std::numeric_limits<float>::max();
815 } else {
816 mass = json.at("mass");
817 }
818
819 physics.setMass(mass);
820 physics.setMode(json.at("mode"));
821
822 if(json.find("collision_response") != json.end()) {
823 physics.mTraits &= ~PhysicsState::MaskCollisionResponse;
824 for(const PhysicsState::CollisionResponse response: json.at("collision_response")) {
825 physics.setCollisionResponse(response);
826 }
827 }
828
829 if(json.find("velocity") != json.end()) {
830 physics.mVelocity = glm::vec3 {
831 json.at("velocity")[0],
832 json.at("velocity")[1],
833 json.at("velocity")[2],
834 };
835 assert(isNumber(physics.mVelocity) && isFinite(physics.mVelocity) && "Velocity must be sensible");
836 }
837
838 if(json.find("angular_velocity") != json.end()) {
839 physics.mAngularVelocity = glm::vec3 {
840 json.at("angular_velocity")[0],
841 json.at("angular_velocity")[1],
842 json.at("angular_velocity")[2],
843 };
844 assert(isNumber(physics.mAngularVelocity) && isFinite(physics.mAngularVelocity) && "Angular velocity must be sensible");
845 }
846
847 if(json.find("force") != json.end()) {
848 physics.mForce = glm::vec3 {
849 json.at("force")[0],
850 json.at("force")[1],
851 json.at("force")[2],
852 };
853 assert(isNumber(physics.mForce) && isFinite(physics.mForce) && "Force must be sensible");
854 }
855
856 if(json.find("torque") != json.end()) {
857 physics.mForce = glm::vec3 {
858 json.at("torque")[0],
859 json.at("torque")[1],
860 json.at("torque")[2],
861 };
862 assert(isNumber(physics.mTorque) && isFinite(physics.mTorque) && "Torque must be sensible");
863 }
864
865 if(json.find("coefficient_friction_static") != json.end()) {
866 physics.mCoefficientFrictionStatic = json.at("coefficient_friction_static");
867 assert(physics.mCoefficientFrictionStatic >= 0.f && "Coefficient friction must be non-negative");
868 }
869
870 if(json.find("coefficient_friction_dynamic") != json.end()) {
871 physics.mCoefficientFrictionDynamic = json.at("coefficient_friction_dynamic");
872 assert(physics.mCoefficientFrictionDynamic >= 0.f && "Coefficient friction must be non-negative");
873 }
874
875 if(json.find("coefficient_restitution") != json.end()) {
876 physics.setCoefficientRestitution(json.at("coefficient_restitution"));
877 }
878 }
879
880 inline void to_json(
881 nlohmann::json& json,
882 const PhysicsState& physics
883 ) {
884 const float mass { physics.getMass() };
885 std::vector<PhysicsState::CollisionResponse> collisionResponse {};
886 if(physics.mTraits&PhysicsState::COLLISION_SEPARATE) {
887 collisionResponse.push_back(PhysicsState::COLLISION_SEPARATE);
888 }
889 if(physics.mTraits&PhysicsState::COLLISION_SIGNAL) {
890 collisionResponse.push_back(PhysicsState::COLLISION_SIGNAL);
891 }
892 json = {
894 mass != std::numeric_limits<float>::max()?
895 nlohmann::json::object({ "mass", mass }):
896 nlohmann::json::object({ "mass", "infinity" }),
897 { "mode", physics.getMode() },
898 { "collision_response", collisionResponse },
899 { "coefficient_friction_static", physics.mCoefficientFrictionStatic },
900 { "coefficient_friction_dynamic", physics.mCoefficientFrictionDynamic },
901 { "coefficient_restitution", physics.mCoefficientRestitution },
902 };
903 }
904
905 template <uint8_t LagrangeCount>
906 inline const std::array<float, LagrangeCount>& Constraint<LagrangeCount>::getLagrange() const {
908 }
909
910 template <uint8_t LagrangeCount>
911 inline const std::array<float, LagrangeCount>& Constraint<LagrangeCount>::getLagrangeDelta() const {
913 }
914
915 template <uint8_t LagrangeCount>
916 inline void Constraint<LagrangeCount>::applyLagrangeDelta(float delta, uint8_t index) {
917 mLagrangeDeltas[index] = delta;
918 mLagrangeMultipliers[index] += delta;
919 }
920
921 template <uint8_t LagrangeCount>
923 resetLagrange(std::make_integer_sequence<uint8_t, LagrangeCount>());
924 }
925
926 template<uint8_t LagrangeCount>
927 template<uint8_t ...indices>
928 inline void Constraint<LagrangeCount>::resetLagrange(std::integer_sequence<uint8_t, indices...> sequence) {
929 ((mLagrangeMultipliers[indices] = mLagrangeDeltas[indices] = 0.f), ...);
930 }
931
932 template<typename TParameter, uint8_t LagrangeCount>
933 inline void ParametrizedConstraint<TParameter, LagrangeCount>::setParameter(BaseConstraint::ParticipantID participant, const TParameter& parameter) {
934 mParameters[participant] = parameter;
935 }
936
937 template<typename TParameter, uint8_t LagrangeCount>
938 inline void ParametrizedConstraint<TParameter, LagrangeCount>::removeParameter(BaseConstraint::ParticipantID participant) {
939 mParameters.erase(participant);
940 }
941
942 template <typename TParameter, uint8_t LagrangeCount>
943 inline const std::unordered_map<BaseConstraint::ParticipantID, TParameter>& ParametrizedConstraint<TParameter, LagrangeCount>::getParameters() const {
944 return mParameters;
945 }
946}
947
948#endif
949
Base class for constraints.
Definition types.hpp:475
virtual void applyConstraintVelocity(const ParticipantTable &states, float substepSeconds)
Applies velocity-based constraint to current set of bounds and physics states.
Definition types.hpp:530
BaseConstraint(float compliance)
Initializes this constraint.
Definition types.hpp:493
virtual void resetLagrange()
Resets all lagrange multipliers, preparing them for a new sequence of constraint solve substeps.
Definition types.hpp:540
float mCompliance
Value greater than equal to zero, inverse of the physical stiffness of this constraint.
Definition types.hpp:486
void setCompliance(float newCompliance)
Sets the compliance value for this constraint.
Definition types.cpp:40
virtual void applyConstraintPosition(const ParticipantTable &states, float substepSeconds)
Applies positional constraint to current set of bounds and physics states.
Definition types.hpp:518
float getCompliance() const
Gets the current compliance value for this constraint.
Definition types.cpp:45
void applyLagrangeDelta(float delta, uint8_t index)
Adds a delta to a lagrange value located at index.
Definition types.hpp:916
const std::array< float, LagrangeCount > & getLagrangeDelta() const
Gets the latest lagrange delta applied to a constraint.
Definition types.hpp:911
const std::array< float, LagrangeCount > & getLagrange() const
Gets the current Lagrange multiplier values for this constraint.
Definition types.hpp:906
Constraint(float compliance)
Initializes this constraint with some initial compliance value.
Definition types.hpp:590
void resetLagrange(std::integer_sequence< uint8_t, ints... > index)
Private implementation for each lagrange multiplier index in need of a reset.
std::array< float, LagrangeCount > mLagrangeDeltas
The last delta applied to the Lagrange multiplier for this constraint.
Definition types.hpp:583
void resetLagrange() override
Sets all lagrange multipliers to 0 in preparation for the next physics update.
Definition types.hpp:922
std::array< float, LagrangeCount > mLagrangeMultipliers
The Lagrange multiplier, computed every substep since the start of the physics simulation till the cu...
Definition types.hpp:577
void setParameter(BaseConstraint::ParticipantID participant, const TParameter &parameter)
Adds a parameter for this constraint.
Definition types.hpp:933
const std::unordered_map< BaseConstraint::ParticipantID, TParameter > & getParameters() const
Returns all parameters known to this constraint.
Definition types.hpp:943
void removeParameter(BaseConstraint::ParticipantID participant)
Removes a parameter belonging to a particular constraint participant.
Definition types.hpp:938
std::unordered_map< BaseConstraint::ParticipantID, TParameter > mParameters
A set of parameters associated with each entity.
Definition types.hpp:633
TParameter getParameter(BaseConstraint::ParticipantID participant) const
Gets parameter belonging to a particular constraint participant.
Definition types.hpp:653
ParametrizedConstraint(float compliance)
Initializes this constraint with some initial compliance value.
Definition types.hpp:640
CollisionResponse
Defines how the object this component is attached to responds to collisions.
Definition types.hpp:190
float computeGeneralizedInverseMassPositional(const ObjectBounds &object, const PhysicsState &physics, const glm::vec3 &correctionPoint, const glm::vec3 &correctionGradient)
Computes the generalized inverse mass used for positional corrections applied by constraints.
Definition types.cpp:411
glm::mat3 computeInertiaRotationalWorld(const glm::vec3 &rotationalInertiaLocal, const glm::quat &orientation)
Returns an objects rotation tensor in the global frame given its tensor in the local frame according ...
ObjectBounds applyImpulseObject(ObjectBounds object, const PhysicsState &physics, const glm::vec3 &impulsePositional, const glm::vec3 &impulsePoint)
Returns object bounds in state it would be post application of a positional impulse.
Definition types.cpp:444
float computeGeneralizedInverseMassRotational(const ObjectBounds &object, const PhysicsState &physics, const glm::vec3 &correctionRotational)
Computes the generalized inverse mass used by constraints to apply strictly rotational corrections.
Definition types.cpp:431
Mode
Defines how the object this component is attached to responds to physics updates.
Definition types.hpp:152
PhysicsState applyImpulsePhysics(const ObjectBounds &object, PhysicsState physics, const glm::vec3 &impulsePositional, const glm::vec3 &impulsePoint)
Returns new physics state after application of global impulse.
Definition types.cpp:468
@ COLLISION_SIGNAL
Whether this object's collision events should be reported (via signal).
Definition types.hpp:201
@ COLLISION_SEPARATE
Whether this object should be separated from the object it collides with.
Definition types.hpp:195
@ MODE_KINEMATIC
Trait indicating that this object will undergo position and orientation updates according to its tran...
Definition types.hpp:168
@ MODE_STATIC
Trait indicating that this object won't undergo any physics system updates whatsoever.
Definition types.hpp:174
@ MODE_DYNAMIC
Trait indicating that this object responds to external forces, including those set externally,...
Definition types.hpp:158
bool isPositiveStrict(float number)
Tests whether a number is strictly positive.
Definition types.hpp:81
bool isNonNegative(float number)
Tests whether a number is non-negative.
Definition types.hpp:112
bool isFinite(float number)
Tests whether a given number is finite.
Definition types.hpp:57
Namespace containing all class definitions and functions related to the ToyMaker engine.
Definition application.hpp:25
Classes and structs representing data related to the engine's spatial query system (the precursor to ...
glm::vec3 mRelativePointContactB
The contact point of object B relative to its own frame.
Definition types.hpp:720
float mCollisionVelocity
The velocity of A's point of contact relative to B at the time the collision took place.
Definition types.hpp:734
float mPenetrationDepth
The shortest distance an object must move along the contact normal in order to be separated from the ...
Definition types.hpp:741
void updateCollisionData(const Collision &collision, const PhysicsState &physicsA, const ObjectBounds &boundsA, const ObjectBounds &boundsAPrev, const PhysicsState &physicsB, const ObjectBounds &boundsB, const ObjectBounds &boundsBPrev)
Caches collision related information shared across position and velocity corrections.
Definition types.cpp:51
glm::vec3 mRelativePointContactA
The contact point of object A relative to its own frame.
Definition types.hpp:702
glm::vec3 mLastPointContactB
The projected last point of contact of object B participating in this constraint.
Definition types.hpp:708
void applyConstraintPosition(const ParticipantTable &states, float substepSeconds) override
Separates intersecting/colliding objects and applies static friction.
Definition types.cpp:140
void updateCollisionDataPartial(const PhysicsState &physicsA, const ObjectBounds &boundsA, const PhysicsState &physicsB, const ObjectBounds &boundsB)
Performs a partial collision data update based on result from previous physics substep.
Definition types.cpp:106
bool mCollided
Whether or not two objects are currently intersecting (and therefore whether they should be separated...
Definition types.hpp:684
void applyConstraintVelocity(const ParticipantTable &states, float substepSeconds) override
Applies dynamic friction.
Definition types.cpp:290
glm::vec3 mCurrentPointContactB
The contact point of object B participating in this constraint in world space.
Definition types.hpp:714
CollisionConstraint()
Initializes constraint with collision data from two potentially intersecting objects.
Definition types.cpp:49
glm::vec3 mCurrentPointContactA
The contact point of object A participating in this constraint in world space.
Definition types.hpp:696
glm::vec3 mContactNormal
Upon collision, points in the direction object B would need to move in order to be separated from obj...
Definition types.hpp:727
glm::vec3 mLastPointContactA
The projected last point of contact of object A participating in this constraint.
Definition types.hpp:690
Data representing everything about a collision.
Definition types.hpp:897
A component defining the true bounds of a spatially queryable object situated somewhere in the world.
Definition types.hpp:926
Component representing the physics state of the body it's attached to at some particular point in tim...
Definition types.hpp:142
glm::vec3 mAngularVelocity
The angular velocity of this object.
Definition types.hpp:251
Mode getMode() const
Returns the physics type associated with this object.
Definition types.hpp:390
void applyForceGlobal(const glm::vec3 &force, const glm::vec3 &atPosition, const ObjectBounds &bounds)
Applies a force force at position atPosition, updating the torque and central force of an object whos...
Definition types.cpp:16
float mCoefficientFrictionStatic
The friction coefficient of the force that prevents relative motion between the surface of two object...
Definition types.hpp:273
bool separatesOnCollision() const
Whether this object is configured to separate from another object it collides with.
Definition types.hpp:429
static const Traits MaskCollisionResponse
Mask used to retrieve the section of an object's physics traits that indicate its collision response ...
Definition types.hpp:209
Traits mTraits
Defines a set of flags that determines how this object responds to physics updates.
Definition types.hpp:296
void setMass(float mass)
Sets the mass of this object.
Definition types.hpp:337
void setCollisionResponse(CollisionResponse response)
Sets a flag related to this object's collision response behaviour.
Definition types.hpp:450
void unsetCollisionResponse(CollisionResponse response)
Unsets a flag related to this object's collision response behaviour.
Definition types.hpp:458
void setRotationalInertia(const glm::vec3 &rotationalInertia)
Sets the rotational inertia for this object along each axis in the object's local frame.
Definition types.hpp:362
glm::vec3 mTorque
Proportional to sum of all forces acting perpendicular to the vector going from the point at which th...
Definition types.hpp:235
void applyForceLocal(const glm::vec3 &force, const glm::vec3 &atPosition, const ObjectBounds &bounds)
Applies a force force at position atPosition, updating the torque and central force of an object whos...
Definition types.cpp:8
void setCoefficientRestitution(float newCoefficient)
Sets the coefficient of restitution for this object.
Definition types.hpp:378
bool signalsOnCollision() const
Whether this object is configured to report when it makes contact with another object.
Definition types.hpp:442
glm::vec3 mForce
The sum of all the forces acting on this object's center of mass, causing it to move through space.
Definition types.hpp:225
void setMode(Mode mode)
Sets the physics type associated with this object.
Definition types.hpp:408
float mMassInverse
The inverse of this object's mass.
Definition types.hpp:266
glm::vec3 mVelocity
The velocity of this object.
Definition types.hpp:243
float mCoefficientRestitution
The fraction of the net kinetic energy prior to a collision retained by a pair of objects after the c...
Definition types.hpp:289
glm::vec3 getRotationalInertia() const
Gets the rotational inertia for this object along each axis in the object's local frame.
Definition types.hpp:350
float mCoefficientFrictionDynamic
The friction coefficient of the force that hinders motion between the surface of two objects when the...
Definition types.hpp:280
glm::vec3 mRotationalInertiaInverse
The inverse of this object's resistance to rotational change.
Definition types.hpp:260
static std::string getComponentTypeName()
Fetches the component type string associated with this class.
Definition types.hpp:216
float getMass() const
Gets the mass of this object.
Definition types.hpp:326
static const Traits MaskMode
Mask used to retrieve the section of an object's physics traits that indicate its update mode.
Definition types.hpp:182