Work on hinges.

This commit is contained in:
Rod Kay
2025-09-05 02:43:49 +10:00
parent 61d6e359ae
commit 7c3ba40482
22 changed files with 2106 additions and 2259 deletions

View File

@@ -18,6 +18,21 @@ is
function lower_Limit (Self : in Item) return Real is abstract;
function upper_Limit (Self : in Item) return Real is abstract;
function Angle (Self : in Item) return Real is abstract;
function limit_Enabled (Self : in Item) return Boolean is abstract;
function reference_Angle (Self : in Item) return Radians is abstract;
function Angle (Self : in Item) return Real is abstract;
function local_Anchor_on_A (Self : in Item) return Vector_3 is abstract;
function local_Anchor_on_B (Self : in Item) return Vector_3 is abstract;
---------
--- Motor
--
function motor_Enabled (Self : in Item) return Boolean is abstract;
function motor_Speed (Self : in Item) return Real is abstract;
function max_motor_Torque (Self : in Item) return Real is abstract;
end physics.Joint.hinge;

View File

@@ -56,4 +56,7 @@ is
function user_Data (Self : in Item) return access lace.Any.limited_item'Class is abstract;
function collide_Connected (Self : in Item) return Boolean is abstract;
end physics.Joint;

View File

@@ -66,6 +66,15 @@ is
end user_Data;
overriding
function collide_Connected (Self : in Item) return Boolean
is
begin
return Boolean'Val (b2d_Joint_collide_Connected (Self.C));
end collide_Connected;
--------
-- DoF6
--
@@ -245,7 +254,7 @@ is
c_Object_B,
c_Pivot_in_A'unchecked_Access,
c_Pivot_in_B'unchecked_Access);
return Self;
return physics.Joint.ball.view (Self);
end new_Ball_Joint;
@@ -408,7 +417,7 @@ is
c_Object_B,
c_Frame_A'unchecked_Access,
c_Frame_B'unchecked_Access);
return Self;
return physics.Joint.slider.view (Self);
end new_Slider_Joint;
@@ -571,7 +580,7 @@ is
c_Object_B,
c_Frame_A'unchecked_Access,
c_Frame_B'unchecked_Access);
return Self;
return physics.Joint.cone_twist.view (Self);
end new_cone_Twist_Joint;
@@ -761,7 +770,7 @@ is
c_math_c.Real (low_Limit),
c_math_c.Real (high_Limit),
Boolean'Pos (collide_Conected));
return Self;
return physics.Joint.hinge.view (Self);
end new_hinge_Joint;
@@ -780,7 +789,7 @@ is
Self.C := b2d_new_space_hinge_Joint (in_Space,
c_Object_A,
c_Frame_A'unchecked_Access);
return Self;
return physics.Joint.hinge.view (Self);
end new_hinge_Joint;
@@ -825,7 +834,7 @@ is
c_math_c.Real (low_Limit),
c_math_c.Real (high_Limit),
Boolean'Pos (collide_Conected));
return Self;
return physics.Joint.hinge.view (Self);
end new_hinge_Joint;
@@ -850,6 +859,7 @@ is
end Limits_are;
overriding
function lower_Limit (Self : in Hinge) return Real
is
@@ -872,8 +882,7 @@ is
function Angle (Self : in Hinge) return Real
is
begin
raise Error with "TODO";
return 0.0;
return Real (b2d_Joint_hinge_Angle (Self.C));
end Angle;
@@ -980,6 +989,68 @@ is
end desired_Extent_is;
overriding
function local_Anchor_on_A (Self : in Hinge) return Vector_3
is
begin
return +b2d_Joint_hinge_local_Anchor_on_A (Self.C);
end local_Anchor_on_A;
overriding
function local_Anchor_on_B (Self : in Hinge) return Vector_3
is
begin
return +b2d_Joint_hinge_local_Anchor_on_B (Self.C);
end local_Anchor_on_B;
overriding
function reference_Angle (Self : in Hinge) return Radians
is
begin
return Radians (b2d_Joint_hinge_reference_Angle (Self.C));
end reference_Angle;
overriding
function limit_Enabled (Self : in Hinge) return Boolean
is
begin
return Boolean'Val (b2d_Joint_hinge_limit_Enabled (Self.C));
end limit_Enabled;
overriding
function motor_Enabled (Self : in Hinge) return Boolean
is
begin
return Boolean'Val (b2d_Joint_hinge_motor_Enabled (Self.C));
end motor_Enabled;
overriding
function motor_Speed (Self : in Hinge) return Real
is
begin
return Real (b2d_Joint_hinge_motor_Speed (Self.C));
end motor_Speed;
overriding
function max_motor_Torque (Self : in Hinge) return Real
is
begin
return Real (b2d_Joint_hinge_max_motor_Torque (Self.C));
end max_motor_Torque;
--------
--- Free
--

View File

@@ -11,6 +11,7 @@ with
lace.Any;
package box2d_Physics.Joint
--
-- Provides glue between a physics joint and a Box2D joint.
@@ -51,9 +52,9 @@ is
low_Limit, high_Limit : in math.Real;
collide_Conected : in Boolean) return physics.Joint.hinge.view;
function new_hinge_Joint (in_Space : in box2d_c.Pointers.Space_Pointer;
Object_A : in physics.Object.view;
Frame_A : in Matrix_4x4) return physics.Joint.hinge.view;
function new_hinge_Joint (in_Space : in box2d_c.Pointers.Space_Pointer;
Object_A : in physics.Object.view;
Frame_A : in Matrix_4x4) return physics.Joint.hinge.view;
procedure free (the_Joint : in out physics.Joint.view);
@@ -78,6 +79,11 @@ private
function user_Data (Self : in Item) return access lace.Any.limited_Item'Class;
overriding
function collide_Connected (Self : in Item) return Boolean;
use physics.Joint;
--------
@@ -341,11 +347,33 @@ private
relaxationFactor : in Real := 1.0);
overriding
function lower_Limit (Self : in Hinge) return Real;
overriding
function upper_Limit (Self : in Hinge) return Real;
overriding
function limit_Enabled (Self : in Hinge) return Boolean;
overriding
function Angle (Self : in Hinge) return Real;
overriding
function reference_Angle (Self : in Hinge) return Radians;
overriding
function local_Anchor_on_A (Self : in Hinge) return Vector_3;
overriding
function local_Anchor_on_B (Self : in Hinge) return Vector_3;
overriding
function motor_Enabled (Self : in Hinge) return Boolean;
overriding
function motor_Speed (Self : in Hinge) return Real;
overriding
function max_motor_Torque (Self : in Hinge) return Real;
end box2d_Physics.Joint;

View File

@@ -269,7 +269,6 @@ is
function new_hinge_Joint (Self : access Item; Object_A : in physics.Object.view;
Frame_A : in Matrix_4x4) return physics.Joint.hinge.view
is
pragma unreferenced (Self);
the_Joint : constant physics.Joint.hinge.view := box2d_physics.Joint.new_hinge_Joint (Self.C, Object_A, Frame_A);
begin
return the_Joint;

View File

@@ -66,6 +66,13 @@ private
overriding
function user_Data (Self : in Item) return access lace.Any.limited_item'Class;
overriding
function collide_Connected (Self : in Item) return Boolean
is
(False);
--------
-- DoF6
@@ -76,8 +83,7 @@ private
null;
end record;
type DoF6_view is access DoF6
;
type DoF6_view is access DoF6;
overriding
procedure destruct (Self : in out DoF6);
@@ -329,5 +335,34 @@ private
overriding
function Angle (Self : in Hinge) return Real;
overriding
function reference_Angle (Self : in Hinge) return Radians
is (raise Program_Error);
overriding
function local_Anchor_on_A (Self : in Hinge) return Vector_3
is (raise Program_Error);
overriding
function local_Anchor_on_B (Self : in Hinge) return Vector_3
is (raise Program_Error);
overriding
function limit_Enabled (Self : in Hinge) return Boolean
is (raise Program_Error);
overriding
function motor_Enabled (Self : in Hinge) return Boolean
is (raise Program_Error);
overriding
function motor_Speed (Self : in Hinge) return Real
is (raise Program_Error);
overriding
function max_motor_Torque (Self : in Hinge) return Real
is (raise Program_Error);
end bullet_Physics.Joint;