3#include "pixelbullet/physics/physics_types.h"
4#include "pixelbullet/serialization/glm_node.h"
5#include "pixelbullet/serialization/node.h"
12 ColliderShapeType shape = ColliderShapeType::Box;
13 glm::vec3 box_half_extents = glm::vec3(0.5f);
14 float sphere_radius = 0.5f;
15 float capsule_radius = 0.5f;
16 float capsule_half_height = 0.5f;
17 glm::vec3 center = glm::vec3(0.0f);
18 float friction = 0.5f;
19 float restitution = 0.0f;
20 bool is_trigger =
false;
27 node[
"enabled"] << component.enabled;
28 std::string shape =
"Box";
29 if (component.shape == ColliderShapeType::Sphere)
33 else if (component.shape == ColliderShapeType::Capsule)
37 node[
"shape"] << shape;
38 node[
"boxHalfExtents"] << component.box_half_extents;
39 node[
"sphereRadius"] << component.sphere_radius;
40 node[
"capsuleRadius"] << component.capsule_radius;
41 node[
"capsuleHalfHeight"] << component.capsule_half_height;
42 node[
"center"] << component.center;
43 node[
"friction"] << component.friction;
44 node[
"restitution"] << component.restitution;
45 node[
"isTrigger"] << component.is_trigger;
51 if (node.HasProperty(
"enabled"))
53 node[
"enabled"] >> component.enabled;
55 if (node.HasProperty(
"shape"))
57 std::string serialized_shape;
58 node[
"shape"] >> serialized_shape;
59 if (serialized_shape ==
"Sphere")
61 component.shape = ColliderShapeType::Sphere;
63 else if (serialized_shape ==
"Capsule")
65 component.shape = ColliderShapeType::Capsule;
69 component.shape = ColliderShapeType::Box;
72 if (node.HasProperty(
"boxHalfExtents"))
74 node[
"boxHalfExtents"] >> component.box_half_extents;
76 if (node.HasProperty(
"sphereRadius"))
78 node[
"sphereRadius"] >> component.sphere_radius;
80 if (node.HasProperty(
"capsuleRadius"))
82 node[
"capsuleRadius"] >> component.capsule_radius;
84 if (node.HasProperty(
"capsuleHalfHeight"))
86 node[
"capsuleHalfHeight"] >> component.capsule_half_height;
88 if (node.HasProperty(
"center"))
90 node[
"center"] >> component.center;
92 if (node.HasProperty(
"friction"))
94 node[
"friction"] >> component.friction;
96 if (node.HasProperty(
"restitution"))
98 node[
"restitution"] >> component.restitution;
100 if (node.HasProperty(
"isTrigger"))
102 node[
"isTrigger"] >> component.is_trigger;
106 component.is_trigger =
false;
Represents a hierarchical node capable of storing various data types and supporting YAML serializatio...
Definition node.h:45
Definition collider_component.h:10