Began work on serializing entity physics data to file

dev
Shariq Shah 7 years ago
parent 8c0433e2be
commit dae9c6d0ef
  1. 3
      README.md
  2. 2
      src/common/common.h
  3. 1
      src/game/physics.c
  4. 52
      src/libsymmetry/entity.c

@ -155,6 +155,8 @@
- ## TODO
- Work on (yet another)entity refactor before moving on to serialization
- Implement collision/physics data serialization, read and write.
- Physics forces/torque etc
- Implement physics debug visualizations for other primitives and tri mesh shapes
- Replace all renderer_check_gl calls with GL_CHECK macro
@ -173,6 +175,7 @@
- Re-order lib folder for linux by putting all libraries in one folder
- Figure out a better way for handling libs on linux, current method DOES NOT work on other computers
- Fix 30fps bug on windows
- Change compilation so that that external libraries are compiled along with the project code(like Urho3d)
- Add fallback shader
- Implement Game States
- Store Materials in new format supported by parser

@ -58,6 +58,8 @@ enum Collision_Shape_Type
CST_BOX = 0,
CST_SPHERE,
CST_CYLINDER,
CST_CAPSULE,
CST_PLANE,
CST_TRIMESH,
CST_UNKNOWN
};

@ -238,6 +238,7 @@ int physics_cs_type_get(Collision_Shape shape)
case dSphereClass: return CST_SPHERE;
case dCylinderClass: return CST_CYLINDER;
case dTriMeshClass: return CST_TRIMESH;
case dPlaneClass: return CST_PLANE;
default: return CST_UNKNOWN;
}
}

@ -238,6 +238,58 @@ bool entity_write(struct Entity* entity, struct Parser_Object* object)
hashmap_int_set(entity_data, "type", entity->type);
hashmap_bool_set(entity_data, "is_listener", entity->is_listener);
hashmap_bool_set(entity_data, "renderable", entity->renderable);
hashmap_bool_set(entity_data, "has_collision", entity->has_collision);
if(entity->has_collision)
{
if(entity->collision.rigidbody)
hashmap_bool_set(entity_data, "has_rigidbody", true);
else
hashmap_bool_set(entity_data, "has_rigidbody", false);
int shape_type = platform->physics.cs_type_get(entity->collision.collision_shape);
hashmap_int_set(entity_data, "collision_shape_type", shape_type);
switch(shape_type)
{
case CST_BOX:
{
float x, y, z;
x = y = z = 0.f;
platform->physics.cs_box_params_get(entity->collision.collision_shape, &x, &y, &z);
hashmap_float_set(entity_data, "collision_shape_x", x);
hashmap_float_set(entity_data, "collision_shape_y", y);
hashmap_float_set(entity_data, "collision_shape_z", z);
}
break;
case CST_SPHERE:
{
float radius = 0.f;
platform->physics.cs_sphere_radius_get(entity->collision.collision_shape);
hashmap_float_set(entity_data, "collision_shape_radius", radius);
}
break;
case CST_CAPSULE:
{
float length = 0.f, radius = 0.f;
platform->physics.cs_capsule_params_get(entity->collision.collision_shape, &radius, &length);
hashmap_float_set(entity_data, "collision_shape_length", length);
hashmap_float_set(entity_data, "collision_shape_radius", radius);
}
break;
case CST_PLANE:
{
float a, b, c, d;
platform->physics.cs_plane_params_get(entity->collision.collision_shape, &a, &b, &c, &d);
hashmap_float_set(entity_data, "collision_shape_a", a);
hashmap_float_set(entity_data, "collision_shape_b", b);
hashmap_float_set(entity_data, "collision_shape_c", c);
hashmap_float_set(entity_data, "collision_shape_d", d);
}
break;
default: break;
}
}
struct Entity* parent = entity_get_parent(entity->id);
hashmap_str_set(entity_data, "parent", parent ? parent->name : "NONE");

Loading…
Cancel
Save