1a648ce4c0b3 — Leonard Ritter 3 months ago
* ODE: more properties
1 files changed, 75 insertions(+), 24 deletions(-)

M tukan/ode/init.sc
M tukan/ode/init.sc +75 -24
@@ 70,6 70,58 @@ inline vector-property2 (T getter setter
             viewing self
             setter self (unpack value)
 
+inline quaternion-property (getter setter)
+    property
+        fn (self)
+            viewing self
+            local q : dQuaternion
+            getter self
+                bitcast &q (mutable @float)
+            fvec4
+                q @ 1; q @ 2; q @ 3; q @ 0
+        fn (self quaternion)
+            viewing self
+            local q : dQuaternion
+            q @ 0 = quaternion.w
+            q @ 1 = quaternion.x
+            q @ 2 = quaternion.y
+            q @ 3 = quaternion.z
+            setter self q
+
+inline quaternion-property2 (getter setter)
+    property
+        fn (self)
+            viewing self
+            let q = (getter self)
+            fvec4
+                q @ 1; q @ 2; q @ 3; q @ 0
+        fn (self quaternion)
+            viewing self
+            local q : dQuaternion
+            q @ 0 = quaternion.w
+            q @ 1 = quaternion.x
+            q @ 2 = quaternion.y
+            q @ 3 = quaternion.z
+            setter self q
+
+inline boolean-property (getter true-setter false-setter)
+    property
+        inline (self)
+            (getter self) as bool
+        fn (self enable)
+            if enable
+                true-setter self
+            else
+                false-setter self
+
+let Mass = dMass
+typedef+ Mass
+    inline... zero (self : &this-type,)
+        dMassSetZero &self
+
+    inline... capsule (self : &this-type, density : float, direction : i32, radius : float, length : float)
+        dMassSetCapsule &self density direction radius length
+
 typedef Body < Wrapper :: dBodyID
     inline __typecall (cls world)
         imply (dBodyCreate world) this-type

          
@@ 86,29 138,23 @@ typedef Body < Wrapper :: dBodyID
         dAreConnectedExcluding self other jointtype
 
     let
-        position = (vector-property2 fvec3 dBodyGetPosition dBodySetPosition)
-        quaternion =
-            property
-                fn (self)
-                    let q = (dBodyGetQuaternion self)
-                    fvec4
-                        q @ 1; q @ 2; q @ 3; q @ 0
-                fn (self quaternion)
-                    local q : dQuaternion
-                    q @ 0 = quaternion.w
-                    q @ 1 = quaternion.x
-                    q @ 2 = quaternion.y
-                    q @ 3 = quaternion.z
-                    dBodySetQuaternion self q
-        kinematic =
+        mass =
             property
                 inline (self)
-                    (dBodyIsKinematic self) as bool
-                fn (self enable)
-                    if enable
-                        dBodySetKinematic self
-                    else
-                        dBodySetDynamic self
+                    local mass : Mass
+                    dBodyGetMass self &mass
+                    mass
+                inline (self mass)
+                    dBodySetMass self &mass
+        position = (vector-property2 fvec3 dBodyGetPosition dBodySetPosition)
+        quaternion = (quaternion-property2 dBodyGetQuaternion dBodySetQuaternion)
+        kinematic = (boolean-property dBodyIsKinematic dBodySetKinematic dBodySetDynamic)
+        enabled = (boolean-property dBodyIsEnabled dBodyEnable dBodyDisable)
+        linear-damping = (property dBodyGetLinearDamping dBodySetLinearDamping)
+        angular-damping = (property dBodyGetAngularDamping dBodySetAngularDamping)
+        linear-damping-threshold = (property dBodyGetLinearDampingThreshold dBodySetLinearDampingThreshold)
+        angular-damping-threshold = (property dBodyGetAngularDampingThreshold dBodySetAngularDampingThreshold)
+        max-angular-speed = (property dBodyGetMaxAngularSpeed dBodySetMaxAngularSpeed)
 
     let _dBodyGetFirstGeom =
         bitcast dBodyGetFirstGeom

          
@@ 261,8 307,10 @@ typedef Space < Wrapper :: dSpaceID
             push;
             let body = geom.body
             if ((storagecast (body as Body)) != null)
-                translate body.position
-                rotate body.quaternion
+                #translate body.position
+                #rotate body.quaternion
+                translate geom.position
+                rotate geom.quaternion
             dispatch geom
             case Plane (geom)
                 # setup object

          
@@ 437,6 485,9 @@ typedef+ GeomType
             _dGeomGetBody
             dGeomSetBody
     let position-offset = (vector-property2 fvec3 dGeomGetOffsetPosition dGeomSetOffsetPosition)
+    let position = (vector-property2 fvec3 dGeomGetPosition dGeomSetPosition)
+    let quaternion = (quaternion-property dGeomGetQuaternion dGeomSetQuaternion)
+    let enabled = (boolean-property dGeomIsEnabled dGeomEnable dGeomDisable)
 
 typedef Plane < GeomType :: dGeomID
     inline... __typecall

          
@@ 768,7 819,7 @@ typedef+ AMotorJoint
 #-------------------------------------------------------------------------------
 
 do
-    let World Space SimpleSpace HashSpace global-space Geom Body
+    let World Space SimpleSpace HashSpace global-space Geom Body Mass
 
     let Plane Sphere Box Cylinder Capsule