PeriDyno 1.0.0
Loading...
Searching...
No Matches
RigidBody.cpp
Go to the documentation of this file.
1#include "RigidBody.h"
2#include "Quat.h"
3
4namespace dyno
5{
7
8 template<typename TDataType>
10 : ParametricModel<TDataType>()
11 {
12 this->setAutoHidden(false);
13 this->setForceUpdate(true);
14 }
15
16 template<typename TDataType>
20
21 template<typename TDataType>
23 {
25
26 Real dt = this->stateTimeStep()->getValue();
27
28 auto center = this->stateCenter()->getValue();
29 auto trans_velocity = this->stateVelocity()->getValue();
30 auto angular_velocity = this->stateAngularVelocity()->getValue();
31
32 auto quat = this->stateQuaternion()->getValue();
33
34 auto rot = this->stateRotationMatrix()->getValue();
35
36 auto inertia = this->stateInertia()->getValue();
37 auto initial_inertia = this->stateInitialInertia()->getValue();
38
39 trans_velocity += this->varGravity()->getValue() * dt;
40 center += trans_velocity * dt;
41
42 quat = quat.normalize();
43 rot = quat.toMatrix3x3();
44
45 quat += dt * 0.5f *
46 Quat(angular_velocity[0], angular_velocity[1], angular_velocity[2], 0.0)
47 * quat;
48
49 inertia = rot * initial_inertia * rot.inverse();
50
51 this->stateCenter()->setValue(center);
52 this->stateVelocity()->setValue(trans_velocity);
53 this->stateQuaternion()->setValue(quat);
54 this->stateRotationMatrix()->setValue(rot);
55 this->stateInertia()->setValue(inertia);
56 }
57
59}
#define DEFINE_CLASS(name)
Definition Object.h:140
#define IMPLEMENT_TCLASS(name, T1)
Definition Object.h:103
Implementation of quaternion.
void setForceUpdate(bool b)
Definition Node.cpp:544
virtual void updateStates()
Definition Node.cpp:141
void setAutoHidden(bool con)
Definition Node.cpp:68
~RigidBody() override
Definition RigidBody.cpp:17
TDataType::Real Real
Definition RigidBody.h:19
dyno::Quat< Real > Quat
Definition RigidBody.h:22
void updateStates() override
Definition RigidBody.cpp:22
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25
vgm::Quat quat
Definition vgMath.h:633