lace_physics_0.1.0_d1cb6621/source/private/bullet/bullet_physics-space.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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
with
     physics.Space,
     physics.Model;

private
with
     bullet_c,
     bullet_c.Pointers,
     bullet_Physics.Object,

     physics.Shape,
     physics.Object,
     physics.Joint.ball,
     physics.Joint.slider,
     physics.Joint.hinge,
     physics.Joint.cone_twist,
     physics.Joint.DoF6,

     ada.Containers.hashed_Maps;

package bullet_Physics.Space
--
-- Provides a Bullet3D implementation of a physical space.
--
is
   type Item is new physics.Space.item with private;
   type View is access all Item'Class;


   -- TODO: Place this in a nested Forge package.
   function to_Space return Item;

   overriding
   function manifold_Count (Self : in     Item) return Natural;
   overriding
   function Manifold       (Self : access Item;   Index : in Positive) return physics.space.a_Manifold;



private

   function Hash (the_C_Object : in bullet_c.Pointers.Object_Pointer) return ada.Containers.Hash_type;
   use type bullet_c.Pointers.Object_pointer;
   use type bullet_Physics.Object.view;
   package c_Object_Maps_of_Object is new ada.Containers.hashed_Maps (Key_type        => bullet_c.Pointers.Object_Pointer,
                                                                      Element_type    => bullet_Physics.Object.view,
                                                                      Hash            => Hash,
                                                                      equivalent_Keys => "=",
                                                                      "="             => "=");

   type Item is new physics.Space.item with
      record
         C          : bullet_c.Pointers.Space_Pointer;
         object_Map : c_Object_Maps_of_Object.Map;
      end record;

   use Math;


   ----------------
   --- Joint Cursor
   --
   type joint_Cursor is new physics.Space.joint_Cursor with null record;

   overriding
   procedure next        (Cursor : in out joint_Cursor);
   overriding
   function  has_Element (Cursor : in     joint_Cursor) return Boolean;
   overriding
   function  Element     (Cursor : in     joint_Cursor) return physics.Joint.view;
   overriding
   function  first_Joint (Self   : in     Item)         return physics.Space.joint_Cursor'Class;


   ----------
   --- Forge
   --

   overriding
   procedure destruct (Self : in out Item);


   ---------
   --- Shape
   --

   overriding
   function              new_Shape (Self : access Item;   Model        : in physics.Model.view)              return physics.Shape.view;
   overriding
   function       new_sphere_Shape (Self : access Item;   Radius       : in Real     := 0.5)                 return physics.Shape.view;
   overriding
   function          new_box_Shape (Self : access Item;   half_Extents : in Vector_3 := (0.5, 0.5, 0.5))     return physics.Shape.view;
   overriding
   function      new_capsule_Shape (Self : access Item;   Radius       : in Real     :=  0.5;
                                                          Height       : in Real)                            return physics.Shape.view;
   overriding
   function         new_cone_Shape (Self : access Item;   Radius       : in Real     :=  0.5;
                                                          Height       : in Real     := 1.0)                 return physics.Shape.view;
   overriding
   function     new_cylinder_Shape (Self : access Item;   half_Extents : in Vector_3 := (0.5, 0.5, 0.5))     return physics.Shape.view;
   overriding
   function  new_heightfield_Shape (Self : access Item;   Heightfield  : in out physics.Heightfield;
                                                          Scale        : in     Vector_3)                    return physics.Shape.view;
   overriding
   function  new_multisphere_Shape (Self : access Item;   Sites        : in physics.Vector_3_array;
                                                          Radii        : in Vector)                          return physics.Shape.view;
   overriding
   function        new_plane_Shape (Self : access Item;   Normal       : in Vector_3 := (0.0, 1.0, 0.0);
                                                          Offset       : in Real     :=  0.0)                return physics.Shape.view;
   overriding
   function  new_convex_hull_Shape (Self : access Item;   Points       : in physics.Vector_3_array)          return physics.Shape.view;
   overriding
   function         new_mesh_Shape (Self : access Item;   Points       : access Physics.Geometry_3D.a_Model) return physics.Shape.view;
   overriding
   function       new_circle_Shape (Self : access Item;   Radius       : in Real     := 0.5)                 return physics.Shape.view;
   overriding
   function      new_polygon_Shape (Self : access Item;   Vertices     : in physics.Space.polygon_Vertices)  return physics.Shape.view;


   ----------
   --- Object
   --

   overriding
   function  new_Object   (Self : access Item;   of_Shape     : in physics.Shape .view;
                                                 of_Mass      : in Real;
                                                 Friction     : in Real;
                                                 Restitution  : in Real;
                                                 at_Site      : in Vector_3;
                                                 is_Kinematic : in Boolean) return physics.Object.view;
   overriding
   function  object_Count (Self : in     Item) return Natural;


   ---------
   --- Joint
   --

   overriding
   function new_hinge_Joint  (Self : access Item;   Object_A,
                                                    Object_B          : in physics.Object.view;
                                                    Anchor_in_A,
                                                    Anchor_in_B       : in Vector_3;
                                                    pivot_Axis        : in Vector_3;
                                                    low_Limit,
                                                    high_Limit        : in Real;
                                                    collide_Connected : in Boolean) return physics.Joint.hinge.view;
   overriding
   function new_hinge_Joint  (Self : access Item;   Object_A,
                                                    Object_B          : in physics.Object.view;
                                                    Frame_A,
                                                    Frame_B           : in Matrix_4x4;
                                                    low_Limit,
                                                    high_Limit        : in Real;
                                                    collide_Connected : in Boolean) return physics.Joint.hinge.view;
   overriding
   function new_hinge_Joint  (Self : access Item;   Object_A   : in physics.Object.view;
                                                    Frame_A    : in Matrix_4x4) return physics.Joint.hinge.view;
   overriding
   function new_DoF6_Joint   (Self : access Item;   Object_A,
                                                    Object_B   : in physics.Object.view;
                                                    Frame_A,
                                                    Frame_B    : in Matrix_4x4) return physics.Joint.DoF6.view;
   overriding
   function new_ball_Joint   (Self : access Item;   Object_A,
                                                    Object_B   : in physics.Object.view;
                                                    Pivot_in_A,
                                                    Pivot_in_B : in Vector_3)   return physics.Joint.ball.view;
   overriding
   function new_slider_Joint (Self : access Item;   Object_A,
                                                    Object_B   : in physics.Object.view;
                                                    Frame_A,
                                                    Frame_B    : in Matrix_4x4) return physics.Joint.slider.view;
   overriding
   function new_cone_twist_Joint (Self : access Item;
                                                    Object_A,
                                                    Object_B   : in physics.Object.view;
                                                    Frame_A,
                                                    Frame_B    : in Matrix_4x4) return physics.Joint.cone_twist.view;
   ---------------
   --- Operations
   --

   overriding
   procedure add        (Self : in out Item;   Object   : in physics.Object.view);
   overriding
   procedure rid        (Self : in out Item;   Object   : in physics.Object.view);

   overriding
   function  cast_Ray   (Self : access Item;   From,
                                               To       : in Vector_3) return physics.Space.ray_Collision;

   overriding
   procedure evolve     (Self : in out Item;   By       : in Duration);

   overriding
   function  Gravity    (Self : in     Item) return Vector_3;
   overriding
   procedure Gravity_is (Self : in out Item;   Now      : in Vector_3);

   overriding
   procedure add        (Self : in out Item;   Joint    : in physics.Joint.view);
   overriding
   procedure rid        (Self : in out Item;   Joint    : in physics.Joint.view);

   overriding
   procedure update_Bounds
                        (Self : in out Item;   of_Obect : in physics.Object.view);

   overriding
   procedure set_Joint_local_Anchor
                        (Self : in out Item;   the_Joint    : in physics.Joint.view;
                                               is_Anchor_A  : in Boolean;
                                               local_Anchor : in Vector_3);

end bullet_Physics.Space;