lace_physics_0.1.0_d1cb6621/source/physics-model.adb

 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
with
     ada.unchecked_Deallocation;

package body physics.Model
is
   ----------
   --- Forge
   --

   package body Forge
   is
      function new_physics_Model (Id          : in model_Id := null_model_Id;
                                  shape_Info  : in a_Shape;
                                  Scale       : in Vector_3 := (1.0, 1.0, 1.0);
                                  Mass        : in Real     := 0.0;
                                  Friction    : in Real     := 0.1;
                                  Restitution : in Real     := 0.1;
                                  --  Site        : in Vector_3 := Origin_3D;
                                  is_Tangible : in Boolean  := True) return View
      is
      begin
         return new Item' (Id          => Id,
                           Scale       => Scale,
                           shape_Info  => shape_Info,
                           Shape       => null,
                           Mass        => Mass,
                           Friction    => Friction,
                           Restitution => Restitution,
                           --  Site        => Site,
                           is_Tangible => is_Tangible);
      end new_physics_Model;
   end Forge;


   procedure define (Self : in out Item;   Scale : in Vector_3)
   is
   begin
      Self.Scale := Scale;
   end define;


   procedure destroy (Self : in out Item)
   is
   begin
      null;
   end destroy;


   procedure free (Self : in out View)
   is
      procedure deallocate is new ada.unchecked_Deallocation (Item'Class,
                                                              View);
   begin
      Self.destroy;
      deallocate (Self);
   end free;


   ---------------
   --- Attributes
   --

   function Id (Self : in Item'Class) return model_Id
   is
   begin
      return Self.Id;
   end Id;


   procedure Id_is (Self : in out Item'Class;   Now : in model_Id)
   is
   begin
      Self.Id := Now;
   end Id_is;


   procedure Scale_is (Self : in out Item'Class;   Now : in Vector_3)
   is
   begin
      Self.Scale := Now;
   end Scale_is;


end physics.Model;