Miloslav Číž 4 лет назад
Родитель
Сommit
91f7c25e1b
2 измененных файлов с 37 добавлено и 1 удалено
  1. 1 1
      test_sdl.c
  2. 36 0
      tinyphysicsengine.h

+ 1 - 1
test_sdl.c

@@ -57,7 +57,7 @@ cubeModel.customTransformMatrix = &m;
 
 TPE_Vec4 p, v;
 
-TPE_vec4Set(&p,-512,512,0,0);
+TPE_vec4Set(&p,0,512,0,0);
 TPE_vec4Set(&v,30,0,0,0);
 
 TPE_bodyApplyVelocity(&body,p,v);

+ 36 - 0
tinyphysicsengine.h

@@ -135,10 +135,46 @@ typedef struct
                                    orientation)  */
 } TPE_RotationState;
 
+
+#define TPE_BODY_SHAPE_SPHERE 0
+#define TPE_BODY_SHAPE_CUBOID 1
+#define TPE_BODY_SHAPE_PLANE 2
+#define TPE_BODY_SHAPE_CYLINDER 3
+#define TPE_BODY_SHAPE_MESH 4
+#define TPE_BODY_SHAPE_MULTIBODY 5
+
+typedef struct
+{
+  TPE_Unit radius;
+} TPE_ShapeSphereParams;
+
+typedef struct
+{
+  TPE_Unit width;
+  TPE_Unit height;
+  TPE_Unit depth;
+} TPE_ShapeCuboidParams;
+
+typedef struct
+{
+  TPE_Unit *vertices;
+  uint16_t vertexCount;
+
+  uint16_t *triangles;
+  uint16_t triangleCount;
+} TPE_ShapeMeshParams;
+
 typedef struct
 {
   uint8_t shape;
 
+  union shapeParams
+  {
+    TPE_ShapeSphereParams sphere;
+    TPE_ShapeCuboidParams cuboid;
+    TPE_ShapeMeshParams mesh;
+  };
+
   TPE_Unit shapeParams[TPE_MAX_SHAPE_PARAMS];  ///< parameters of the body type
   void *shapeParamPointers[TPE_MAX_SHAPE_PARAMPOINTERS]; ///< pointer parameters