chipmunk2d_0.1.0_3fa66f62/src/chipmunk.ads

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
with Interfaces.C;
use Interfaces.C;
with System;

package Chipmunk
  with Preelaborate
is

   subtype cpFloat is Interfaces.C.double;

   function Infinity return cpFloat;
   pragma Import (C, Infinity, "cpFloat_inf");

   subtype cpBool is Interfaces.C.C_bool;

   type cpCollisionType is new Interfaces.C.unsigned;
   subtype cpDataPointer is System.Address;
   subtype cpTimestamp is Interfaces.C.unsigned;
   subtype cpBitmask is Interfaces.C.unsigned;

   type cpBodyType is (Dynamic, Kinematic, Static) with Convention => C;

   type cpBody is new System.Address;

   type cpShape is new System.Address;
   subtype cpCircleShape is cpShape;
   subtype cpSegmentShape is cpShape;
   subtype cpPolyShape is cpShape;

   type cpConstraint is new System.Address;
   subtype cpDampedSpring is cpConstraint;
   subtype cpDampedRotarySpring is cpConstraint;
   subtype cpPivotJoint is cpConstraint;
   subtype cpPinJoint is cpConstraint;
   subtype cpGearJoint is cpConstraint;
   subtype cpSlideJoint is cpConstraint;
   subtype cpSimpleMotor is cpConstraint;
   subtype cpRatchetJoint is cpConstraint;
   subtype cpRotaryLimitJoint is cpConstraint;
   subtype cpGrooveJoint is cpConstraint;

   type cpArbiter is new System.Address;
   type cpSpace is new System.Address;
   type cpShapeFilter is new System.Address;

   type cpContactPointSet is new System.Address;

   type cpCollisionBeginFunc is
     access function
       (Arb : cpArbiter; Space : cpSpace; User_Data : cpDataPointer)
        return cpBool
   with Convention => C;
   --  Collision begin event function callback type. Returning false from a
   --  begin callback causes the collision to be ignored until the the separate
   --  callback is called when the objects stop colliding.

   type cpCollisionPreSolveFunc is
     access function
       (Arb : cpArbiter; Space : cpSpace; User_Data : cpDataPointer)
        return cpBool
   with Convention => C;
   --  Collision pre-solve event function callback type. Returning false from
   --  a pre-step callback causes the collision to be ignored until the next
   --  step.

   type cpCollisionPostSolveFunc is
     access procedure
       (Arb : cpArbiter; Space : cpSpace; User_Data : cpDataPointer)
   with Convention => C;
   --  Collision post-solve event function callback type.

   type cpCollisionSeparateFunc is
     access procedure
       (Arb : cpArbiter; Space : cpSpace; User_Data : cpDataPointer)
   with Convention => C;
   --  Collision separate event function callback type.

   --  Struct that holds function callback pointers to configure custom
   --  collision handling. Collision handlers have a pair of types; when a
   --  collision occurs between two shapes that have these types, the collision
   --  handler functions are triggered.
   type cpCollisionHandler is record
      --  Collision type identifier of the first shape that this handler
      --  recognizes. In the collision handler callback, the shape with
      --  this type will be the first argument. Read only.
      typeA : cpCollisionType;

      --  Collision type identifier of the second shape that this handler
      --  recognizes. In the collision handler callback, the shape with
      --  this type will be the second argument. Read only.
      typeB : cpCollisionType;

      --  This function is called when two shapes with types that match this
      --  collision handler begin colliding.
      beginFunc : cpCollisionBeginFunc;

      --  This function is called each step when two shapes with types that
      --  match this collision handler are colliding. It's called before the
      --  collision solver runs so that you can affect a collision's outcome.
      preSolveFunc : cpCollisionPreSolveFunc;

      --  This function is called each step when two shapes with types that
      --  match this collision handler are colliding. It's called after the
      --  collision solver runs so that you can read back information about
      --  the collision to trigger events in your game.
      postSolveFunc : cpCollisionPostSolveFunc;

      --  This function is called when two shapes with types that match this
      --  collision handler stop colliding.
      separateFunc : cpCollisionSeparateFunc;

      --  This is a user definable context pointer that is passed to all of the
      --  collision handler functions.
      userData : cpDataPointer;
   end record
   with Convention => C_Pass_By_Copy;

   type cpGroup is new System.Address;

   type cpPointQueryInfo is new System.Address;
   type cpSegmentQueryInfo is new System.Address;
   type cpBB is new System.Address;

   type cpVect is record
      X, Y : cpFloat;
   end record
   with Convention => C_Pass_By_Copy;

   type C_cpVect_Array is array (Interfaces.C.unsigned) of cpVect
   with Convention => C;

   type cpTransform is record
      A, B, C, D, TX, TY : cpFloat;
   end record
   with Convention => C_Pass_By_Copy;

   type cpMat2x2 is record
      A, B, C, D : cpFloat;
   end record
   with Convention => C_Pass_By_Copy;

   type cpSpaceDebugColor is record
      R, G, B, A : C_float;
   end record
   with Convention => C_Pass_By_Copy;

   type cpSpaceDebugDrawFlags is new Interfaces.Unsigned_16;
   DEBUG_DRAW_SHAPES           : constant cpSpaceDebugDrawFlags := 2#0001#;
   DEBUG_DRAW_CONSTRAINTS      : constant cpSpaceDebugDrawFlags := 2#0010#;
   DEBUG_DRAW_COLLISION_POINTS : constant cpSpaceDebugDrawFlags := 2#0100#;

   function cpMomentForCircle
     (Mass, R1, R2 : cpFloat; Offset : cpVect) return cpFloat;
   pragma Import (C, cpMomentForCircle, "cpMomentForCircle");

   function cpAreaForCircle (R1, R2 : cpFloat) return cpFloat;
   pragma Import (C, cpAreaForCircle, "cpAreaForCircle");

   function cpMomentForSegment
     (Mass : cpFloat; A, B : cpVect; Radius : cpFloat) return cpFloat;
   pragma Import (C, cpMomentForSegment, "cpMomentForSegment");

   function cpAreaForSegment (A, B : cpVect; Radius : cpFloat) return cpFloat;
   pragma Import (C, cpAreaForSegment, "cpAreaForSegment");

   function cpMomentForPoly
     (Mass   : cpFloat;
      Count  : Interfaces.C.int;
      verts  : access C_cpVect_Array;
      Offset : cpVect;
      Radius : cpFloat) return cpFloat;
   pragma Import (C, cpMomentForPoly, "cpMomentForPoly");

   function cpAreaForPoly
     (Count  : Interfaces.C.int;
      verts  : access C_cpVect_Array;
      Radius : cpFloat) return cpFloat;
   pragma Import (C, cpAreaForPoly, "cpAreaForSegment");

   function cpCentroidForPoly
     (Count : Interfaces.C.int; verts : access C_cpVect_Array) return cpVect;
   pragma Import (C, cpCentroidForPoly, "cpCentroidForSegment");

   function cpMomentForBox (Mass, Width, Height : cpFloat) return cpFloat;
   pragma Import (C, cpMomentForBox, "cpMomentForBox");

end Chipmunk;