3#include "pixelbullet/physics/physics_types.h"
4#include "pixelbullet/serialization/node.h"
11 RigidBodyMotionType motion_type = RigidBodyMotionType::Dynamic;
13 float linear_damping = 0.05f;
14 float angular_damping = 0.05f;
15 float gravity_scale = 1.0f;
22 node[
"enabled"] << component.enabled;
23 switch (component.motion_type)
25 case RigidBodyMotionType::Kinematic:
26 node[
"motionType"] << std::string(
"Kinematic");
28 case RigidBodyMotionType::Dynamic:
29 node[
"motionType"] << std::string(
"Dynamic");
32 node[
"motionType"] << std::string(
"Static");
35 node[
"mass"] << component.mass;
36 node[
"linearDamping"] << component.linear_damping;
37 node[
"angularDamping"] << component.angular_damping;
38 node[
"gravityScale"] << component.gravity_scale;
44 if (node.HasProperty(
"enabled"))
46 node[
"enabled"] >> component.enabled;
48 if (node.HasProperty(
"motionType"))
50 std::string serialized_motion_type;
51 node[
"motionType"] >> serialized_motion_type;
52 if (serialized_motion_type ==
"Kinematic")
54 component.motion_type = RigidBodyMotionType::Kinematic;
56 else if (serialized_motion_type ==
"Dynamic")
58 component.motion_type = RigidBodyMotionType::Dynamic;
62 component.motion_type = RigidBodyMotionType::Static;
65 if (node.HasProperty(
"mass"))
67 node[
"mass"] >> component.mass;
69 if (node.HasProperty(
"linearDamping"))
71 node[
"linearDamping"] >> component.linear_damping;
73 if (node.HasProperty(
"angularDamping"))
75 node[
"angularDamping"] >> component.angular_damping;
77 if (node.HasProperty(
"gravityScale"))
79 node[
"gravityScale"] >> component.gravity_scale;
Represents a hierarchical node capable of storing various data types and supporting YAML serializatio...
Definition node.h:45
Definition rigid_body_component.h:9