Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
enphysics.c
Go to the documentation of this file.
1 
6 typedef int[] dGeom;
7 typedef int[] dJoint;
8 typedef int[] dBlock;
9 
10 proto native int dGetNumDynamicBodies(notnull IEntity worldEnt);
11 proto native IEntity dGetDynamicBody(notnull IEntity worldEnt, int index);
12 proto native void dSetInteractionLayer(notnull IEntity worldEntity, int mask1, int mask2, bool enable);
13 proto native bool dGetInteractionLayer(notnull IEntity worldEntity, int mask1, int mask2);
14 
16 proto native vector dGetGravity(notnull IEntity worldEntity);
18 proto native void dSetGravity(notnull IEntity worldEntity, vector g);
20 proto native void dSetTimeSlice(notnull IEntity worldEntity, float timeSlice);
21 
27 //proto native int dMaterialClone(string target, string source, int material_index)
28 //proto native int dMaterialGetType(string source)
29 //proto native int dMaterialSetType(string source, int material_index)
30 
32 {
33  string Name;
34  dGeom Geometry;
35  vector Frame[4] = {Vector(1, 0, 0), Vector(0, 1, 0), Vector(0, 0, 1), Vector(0, 0, 0)};
36  int ParentNode = -1;
37  string MaterialName;
38  int LayerMask; //<Bit mask of layers we are in
39 
40 
41  void PhysicsGeomDef(string name, dGeom geom, string materialName, int layerMask)
42  {
43  Name = name;
44  Geometry = geom;
45  MaterialName = materialName;
46  LayerMask = layerMask;
47  }
48 };
49 
58 proto bool dBodyCreateStaticEx(notnull IEntity ent, PhysicsGeomDef geoms[]);
59 proto bool dBodyCreateGhostEx(notnull IEntity ent, PhysicsGeomDef geoms[]);
60 
71 proto bool dBodyCreateDynamicEx(notnull IEntity ent, vector centerOfMass, float mass, PhysicsGeomDef geoms[]);
72 
74 proto native void dBodyDestroy(notnull IEntity ent);
75 
77 proto native bool dBodyIsSet(notnull IEntity ent);
78 
79 proto native void dBodySetInteractionLayer(notnull IEntity ent, int mask);
80 proto native int dBodyGetInteractionLayer(notnull IEntity ent);
81 proto native void dBodySetGeomInteractionLayer(notnull IEntity ent, int index, int mask);
82 proto native int dBodyGetGeomInteractionLayer(notnull IEntity ent, int index);
83 
86 {
90 };
91 
92 proto native void dBodyActive(notnull IEntity ent, ActiveState activeState);
93 proto native void dBodyDynamic(notnull IEntity ent, bool dynamic);
94 proto native bool dBodyIsDynamic(notnull IEntity ent);
95 
96 proto native bool dBodyIsActive(notnull IEntity ent);
97 proto native bool dBodyEnableGravity(notnull IEntity ent, bool enable);
98 proto native void dBodySetDamping(notnull IEntity ent, float linearDamping, float angularDamping);
99 proto native void dBodySetSleepingTreshold(notnull IEntity body, float linearTreshold, float angularTreshold);
100 
101 proto native bool dBodyIsSolid(notnull IEntity ent);
102 proto native void dBodySetSolid(notnull IEntity ent, bool solid);
103 
111 proto native void dBodyEnableCCD(notnull IEntity body, float maxMotion, float sphereCastRadius);
115 proto native void dBodySetLinearFactor(notnull IEntity body, vector linearFactor);
116 
118 proto native vector dBodyGetCenterOfMass(notnull IEntity body);
119 
132 proto native vector GetVelocity(notnull IEntity ent);
133 
139 proto native void SetVelocity(notnull IEntity ent, vector vel);
140 
144 proto native dBlock dBodyCollisionBlock(notnull IEntity ent1, notnull IEntity ent2);
145 proto native void dBodyRemoveBlock(notnull IEntity worldEntity, dBlock block);
146 
147 proto native void dBodySetInertiaTensorV(notnull IEntity body, vector v);
148 proto native void dBodySetInertiaTensorM(notnull IEntity body, vector m[3]);
149 
150 proto native float dBodyGetMass(notnull IEntity ent);
151 proto native void dBodySetMass(notnull IEntity body, float mass);
152 
153 proto native void dBodyApplyTorqueImpulse(notnull IEntity ent, vector torqueImpulse);
154 proto native vector dBodyGetInvInertiaDiagLocal(notnull IEntity ent);
155 proto native float dBodyComputeImpulseDenominator(notnull IEntity ent, vector position, vector normal);
156 proto native float dBodyComputeAngularImpulseDenominator(notnull IEntity ent, vector axis);
157 proto native vector dBodyGetLocalInertia(notnull IEntity ent);
158 
159 proto void dBodyGetInvInertiaTensorWorld(notnull IEntity body, out vector inertiaTensorWS[3]);
160 
164 proto void dBodyApplyImpulseAt(notnull IEntity body, vector impulse, vector pos);
165 
169 proto void dBodyApplyImpulse(notnull IEntity body, vector impulse);
170 
174 proto void dBodyApplyForce(notnull IEntity body, vector force);
175 
179 proto void dBodyApplyForceAt(notnull IEntity body, vector pos, vector force);
180 
181 proto native void dBodyApplyTorque(notnull IEntity body, vector torque);
182 
186 proto vector dBodyGetAngularVelocity(notnull IEntity body);
187 
193 proto void dBodySetAngularVelocity(notnull IEntity body, vector angvel);
194 
198 proto native void dBodySetTargetMatrix(notnull IEntity body, vector matrix[4], float timeslice);
199 proto native float dBodyGetKineticEnergy(notnull IEntity body);
200 
201 proto native vector dBodyGetVelocityAt(notnull IEntity body, vector globalpos);
203 
209 proto native dGeom dGeomCreateBox(vector size);
211 
213 proto native dGeom dGeomCreateSphere(float radius);
214 
216 proto native dGeom dGeomCreateCapsule(float radius, vector extent);
217 
219 proto native dGeom dGeomCreateCylinder(float radius, vector extent);
220 
222 proto native void dGeomDestroy(dGeom geom);
223 
224 //proto native int dBodyAddGeom(notnull IEntity body, dGeom geom, vector frame[4], string material, int interactionLayer);
225 // find a geometry by its name and returns its index or -1 if the geometry wasn't found
226 proto native int dBodyGetGeom(notnull IEntity ent, string name);
227 // returns number of geometries of the entity
228 proto native int dBodyGetNumGeoms(notnull IEntity ent);
230 
236 proto native dJoint dJointCreateHinge(notnull IEntity ent1, notnull IEntity ent2, vector point1, vector axis1, vector point2, vector axis2, bool block, float breakThreshold);
237 proto native dJoint dJointCreateHinge2(notnull IEntity ent1, notnull IEntity ent2, vector matrix1[4], vector matrix2[4], bool block, float breakThreshold);
238 proto native dJoint dJointCreateSlider(notnull IEntity ent1, notnull IEntity ent2, vector matrix1[4], vector matrix2[4], bool block, float breakThreshold);
239 proto native dJoint dJointCreateBallSocket(notnull IEntity ent1, notnull IEntity ent2, vector point1, vector point2, bool block, float breakThreshold);
240 proto native dJoint dJointCreateFixed(notnull IEntity ent1, notnull IEntity ent2, vector point1, vector point2, bool block, float breakThreshold);
241 proto native dJoint dJointCreateConeTwist(notnull IEntity ent1, notnull IEntity ent2, vector matrix1[4], vector matrix2[4], bool block, float breakThreshold);
242 proto native dJoint dJointCreate6DOF(notnull IEntity ent1, notnull IEntity ent2, vector matrix1[4], vector matrix2[4], bool block, float breakThreshold);
243 proto native dJoint dJointCreate6DOFSpring(notnull IEntity ent1, notnull IEntity ent2, vector matrix1[4], vector matrix2[4], bool block, float breakThreshold);
244 proto native void dJointDestroy(dJoint joint);
245 
246 //only hinge joint
247 proto native void dJointHingeSetLimits(dJoint joint, float low, float high, float softness, float biasFactor, float relaxationFactor);
248 proto native void dJointHingeSetAxis(dJoint joint, vector axis);
249 proto native void dJointHingeSetMotorTargetAngle(dJoint joint, float angle, float dt, float maxImpulse);
250 
251 //only cone-twist joint
252 proto native void dJointConeTwistSetAngularOnly(dJoint joint, bool angularOnly);
253 // setLimit(), a few notes:
254 // _softness:
255 // 0->1, recommend ~0.8->1.
256 // describes % of limits where movement is free.
257 // beyond this softness %, the limit is gradually enforced until the "hard" (1.0) limit is reached.
258 // _biasFactor:
259 // 0->1?, recommend 0.3 +/-0.3 or so.
260 // strength with which constraint resists zeroth order (angular, not angular velocity) limit violation.
261 // __relaxationFactor:
262 // 0->1, recommend to stay near 1.
263 // the lower the value, the less the constraint will fight velocities which violate the angular limits.
264 proto native void dJointConeTwistSetLimit(dJoint joint, int limitIndex, float limitValue);
265 proto native void dJointConeTwistSetLimits(dJoint joint, float _swingSpan1, float _swingSpan2, float _twistSpan, float _softness, float _biasFactor, float _relaxationFactor);
266 
267 //only 6DOF & 6DOFSpring.
274 proto native void dJoint6DOFSetLinearLimits(dJoint joint, vector linearLower, vector linearUpper);
275 proto native void dJoint6DOFSetAngularLimits(dJoint joint, vector angularLower, vector angularUpper);
276 proto native void dJoint6DOFSetLimit(dJoint joint, int axis, float lo, float hi);
277 
278 //when stiffness == -1 && damping == -1, spring is disabled
279 proto native void dJoint6DOFSpringSetSpring(dJoint joint, int axis, float stiffness, float damping);
280 
281 //only slider joint
282 proto native void dJointSliderSetLinearLimits(dJoint joint, float lowerLimit, float upperLimit);
283 proto native void dJointSliderSetAngularLimits(dJoint joint, float lowerLimit, float upperLimit);
284 proto native void dJointSliderSetDirLinear(dJoint joint, float softness, float restitution, float damping);
285 proto native void dJointSliderSetDirAngular(dJoint joint, float softness, float restitution, float damping);
286 proto native void dJointSliderSetLimLinear(dJoint joint, float softness, float restitution, float damping);
287 proto native void dJointSliderSetLimAngular(dJoint joint, float softness, float restitution, float damping);
288 proto native void dJointSliderSetOrthoLinear(dJoint joint, float softness, float restitution, float damping);
289 proto native void dJointSliderSetOrthoAngular(dJoint joint, float softness, float restitution, float damping);
290 //if force == 0, motor is off
291 proto native void dJointSliderSetLinearMotor(dJoint joint, float velocity, float force);
292 proto native void dJointSliderSetAngularMotor(dJoint joint, float velocity, float force);
293 proto native float dJointSliderGetLinearPos(dJoint joint);
294 proto native float dJointSliderGetAngularPos(dJoint joint);
296 
297 //-----------------------------------------------------------------
298 typedef int[] dMaterial;
299 
300 class Contact
301 {
302  private void Contact() {}
303  private void ~Contact() {}
304 
305  dMaterial Material1;
306  dMaterial Material2;
307  int MaterialIndex1;
308  int MaterialIndex2;
309  int Index1;
310  int Index2;
311 
312  float PenetrationDepth;
313 
314  float Impulse;
315  float RelativeNormalVelocityBefore;
316  float RelativeNormalVelocityAfter;
317 
318  vector Normal;
319  vector Position;
320  vector RelativeVelocityBefore;
321  vector RelativeVelocityAfter;
322 
323  proto native vector GetNormalImpulse();
324  proto native float GetRelativeVelocityBefore(vector vel);
325  proto native float GetRelativeVelocityAfter(vector vel);
326 };
PhysicsGeomDef
Definition: enphysics.c:31
dSetTimeSlice
proto native void dSetTimeSlice(notnull IEntity worldEntity, float timeSlice)
Changes fixed time-slice. Default is 1/40, thus simulation runs on 40fps. With smaller values,...
dBodySetInertiaTensorV
proto native void dBodySetInertiaTensorV(notnull IEntity body, vector v)
SetVelocity
proto native void SetVelocity(notnull IEntity ent, vector vel)
Sets linear velocity (for Rigid bodies)
dJointConeTwistSetLimits
proto native void dJointConeTwistSetLimits(dJoint joint, float _swingSpan1, float _swingSpan2, float _twistSpan, float _softness, float _biasFactor, float _relaxationFactor)
dBodyGetInteractionLayer
proto native int dBodyGetInteractionLayer(notnull IEntity ent)
dJointSliderSetAngularLimits
proto native void dJointSliderSetAngularLimits(dJoint joint, float lowerLimit, float upperLimit)
dBodyComputeAngularImpulseDenominator
proto native float dBodyComputeAngularImpulseDenominator(notnull IEntity ent, vector axis)
dBodyApplyTorque
proto native void dBodyApplyTorque(notnull IEntity body, vector torque)
dJointSliderGetAngularPos
proto native float dJointSliderGetAngularPos(dJoint joint)
dBlock
int[] dBlock
Definition: enphysics.c:8
dBodyGetKineticEnergy
proto native float dBodyGetKineticEnergy(notnull IEntity body)
dSetGravity
proto native void dSetGravity(notnull IEntity worldEntity, vector g)
Changes global gravity.
dBodyGetCenterOfMass
proto native vector dBodyGetCenterOfMass(notnull IEntity body)
returns center of mass offset
dBodyEnableCCD
proto native void dBodyEnableCCD(notnull IEntity body, float maxMotion, float sphereCastRadius)
dJointCreateFixed
proto native dJoint dJointCreateFixed(notnull IEntity ent1, notnull IEntity ent2, vector point1, vector point2, bool block, float breakThreshold)
dBodyGetMass
proto native float dBodyGetMass(notnull IEntity ent)
dJointCreate6DOFSpring
proto native dJoint dJointCreate6DOFSpring(notnull IEntity ent1, notnull IEntity ent2, vector matrix1[4], vector matrix2[4], bool block, float breakThreshold)
dBodyEnableGravity
proto native bool dBodyEnableGravity(notnull IEntity ent, bool enable)
dBodyApplyImpulse
proto void dBodyApplyImpulse(notnull IEntity body, vector impulse)
Applies impuls on a rigidbody (origin)
dBodyComputeImpulseDenominator
proto native float dBodyComputeImpulseDenominator(notnull IEntity ent, vector position, vector normal)
dJointSliderSetLimLinear
proto native void dJointSliderSetLimLinear(dJoint joint, float softness, float restitution, float damping)
dJointCreateHinge
proto native dJoint dJointCreateHinge(notnull IEntity ent1, notnull IEntity ent2, vector point1, vector axis1, vector point2, vector axis2, bool block, float breakThreshold)
Managed
TODO doc.
Definition: enscript.c:117
ActiveState
ActiveState
state of a rigidbody
Definition: enphysics.c:85
dBodyCreateGhostEx
proto bool dBodyCreateGhostEx(notnull IEntity ent, PhysicsGeomDef geoms[])
dBodySetInertiaTensorM
proto native void dBodySetInertiaTensorM(notnull IEntity body, vector m[3])
dBodyActive
proto native void dBodyActive(notnull IEntity ent, ActiveState activeState)
dGeom
int[] dGeom
Definition: enphysics.c:6
dBodyDestroy
proto native void dBodyDestroy(notnull IEntity ent)
Destroys attached physics body.
dBodySetSolid
proto native void dBodySetSolid(notnull IEntity ent, bool solid)
dBodyGetLocalInertia
proto native vector dBodyGetLocalInertia(notnull IEntity ent)
dBodyApplyImpulseAt
proto void dBodyApplyImpulseAt(notnull IEntity body, vector impulse, vector pos)
Applies impuls on a pos position in world coordinates.
dBodyApplyTorqueImpulse
proto native void dBodyApplyTorqueImpulse(notnull IEntity ent, vector torqueImpulse)
dJoint
int[] dJoint
Definition: enphysics.c:7
dJointCreateSlider
proto native dJoint dJointCreateSlider(notnull IEntity ent1, notnull IEntity ent2, vector matrix1[4], vector matrix2[4], bool block, float breakThreshold)
dBodySetAngularVelocity
proto void dBodySetAngularVelocity(notnull IEntity body, vector angvel)
Changed an angular velocity.
dBodyCollisionBlock
proto native dBlock dBodyCollisionBlock(notnull IEntity ent1, notnull IEntity ent2)
Disables collisions between two entities.
dBodySetGeomInteractionLayer
proto native void dBodySetGeomInteractionLayer(notnull IEntity ent, int index, int mask)
dJointCreateConeTwist
proto native dJoint dJointCreateConeTwist(notnull IEntity ent1, notnull IEntity ent2, vector matrix1[4], vector matrix2[4], bool block, float breakThreshold)
dJoint6DOFSetAngularLimits
proto native void dJoint6DOFSetAngularLimits(dJoint joint, vector angularLower, vector angularUpper)
dJointSliderSetOrthoLinear
proto native void dJointSliderSetOrthoLinear(dJoint joint, float softness, float restitution, float damping)
dJointCreate6DOF
proto native dJoint dJointCreate6DOF(notnull IEntity ent1, notnull IEntity ent2, vector matrix1[4], vector matrix2[4], bool block, float breakThreshold)
dBodySetTargetMatrix
proto native void dBodySetTargetMatrix(notnull IEntity body, vector matrix[4], float timeslice)
Sets target transformation. If timeslice == dt (simulation step delta time), it will happen in next s...
dBodySetLinearFactor
proto native void dBodySetLinearFactor(notnull IEntity body, vector linearFactor)
IEntity
Definition: enentity.c:164
dJointCreateHinge2
proto native dJoint dJointCreateHinge2(notnull IEntity ent1, notnull IEntity ent2, vector matrix1[4], vector matrix2[4], bool block, float breakThreshold)
dJointHingeSetMotorTargetAngle
proto native void dJointHingeSetMotorTargetAngle(dJoint joint, float angle, float dt, float maxImpulse)
dSetInteractionLayer
proto native void dSetInteractionLayer(notnull IEntity worldEntity, int mask1, int mask2, bool enable)
dBodyGetGeom
proto native int dBodyGetGeom(notnull IEntity ent, string name)
dJointSliderSetOrthoAngular
proto native void dJointSliderSetOrthoAngular(dJoint joint, float softness, float restitution, float damping)
dJointSliderGetLinearPos
proto native float dJointSliderGetLinearPos(dJoint joint)
dJointHingeSetLimits
proto native void dJointHingeSetLimits(dJoint joint, float low, float high, float softness, float biasFactor, float relaxationFactor)
dBodyCreateDynamicEx
proto bool dBodyCreateDynamicEx(notnull IEntity ent, vector centerOfMass, float mass, PhysicsGeomDef geoms[])
dJointSliderSetLinearMotor
proto native void dJointSliderSetLinearMotor(dJoint joint, float velocity, float force)
dBodyDynamic
proto native void dBodyDynamic(notnull IEntity ent, bool dynamic)
dBodyIsSet
proto native bool dBodyIsSet(notnull IEntity ent)
Has the entity attached physics body?
vector
Definition: enconvert.c:105
dMaterial
int[] dMaterial
Definition: enphysics.c:298
dJointConeTwistSetAngularOnly
proto native void dJointConeTwistSetAngularOnly(dJoint joint, bool angularOnly)
dBodyGetInvInertiaTensorWorld
proto void dBodyGetInvInertiaTensorWorld(notnull IEntity body, out vector inertiaTensorWS[3])
dBodyRemoveBlock
proto native void dBodyRemoveBlock(notnull IEntity worldEntity, dBlock block)
dBodyGetInvInertiaDiagLocal
proto native vector dBodyGetInvInertiaDiagLocal(notnull IEntity ent)
dJoint6DOFSpringSetSpring
proto native void dJoint6DOFSpringSetSpring(dJoint joint, int axis, float stiffness, float damping)
MaterialName
owned string MaterialName
Definition: enworld.c:166
dBodySetDamping
proto native void dBodySetDamping(notnull IEntity ent, float linearDamping, float angularDamping)
Contact
Definition: enphysics.c:300
dBodyIsDynamic
proto native bool dBodyIsDynamic(notnull IEntity ent)
dJointDestroy
proto native void dJointDestroy(dJoint joint)
INACTIVE
@ INACTIVE
Definition: enphysics.c:88
dJointSliderSetLimAngular
proto native void dJointSliderSetLimAngular(dJoint joint, float softness, float restitution, float damping)
dBodyIsActive
proto native bool dBodyIsActive(notnull IEntity ent)
dJointSliderSetDirLinear
proto native void dJointSliderSetDirLinear(dJoint joint, float softness, float restitution, float damping)
dJoint6DOFSetLinearLimits
proto native void dJoint6DOFSetLinearLimits(dJoint joint, vector linearLower, vector linearUpper)
dBodySetMass
proto native void dBodySetMass(notnull IEntity body, float mass)
dGetDynamicBody
proto native IEntity dGetDynamicBody(notnull IEntity worldEnt, int index)
dGetNumDynamicBodies
proto native int dGetNumDynamicBodies(notnull IEntity worldEnt)
dBodyGetAngularVelocity
proto vector dBodyGetAngularVelocity(notnull IEntity body)
Gets angular velocity for a rigidbody.
dBodySetSleepingTreshold
proto native void dBodySetSleepingTreshold(notnull IEntity body, float linearTreshold, float angularTreshold)
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
dGetGravity
proto native vector dGetGravity(notnull IEntity worldEntity)
Gets global gravity.
dGetInteractionLayer
proto native bool dGetInteractionLayer(notnull IEntity worldEntity, int mask1, int mask2)
dJoint6DOFSetLimit
proto native void dJoint6DOFSetLimit(dJoint joint, int axis, float lo, float hi)
dBodyIsSolid
proto native bool dBodyIsSolid(notnull IEntity ent)
dGeomCreateBox
proto native dGeom dGeomCreateBox(vector size)
Creates box geometry.
dBodyCreateStaticEx
proto bool dBodyCreateStaticEx(notnull IEntity ent, PhysicsGeomDef geoms[])
ACTIVE
@ ACTIVE
Definition: enphysics.c:87
dJointSliderSetAngularMotor
proto native void dJointSliderSetAngularMotor(dJoint joint, float velocity, float force)
dBodySetInteractionLayer
proto native void dBodySetInteractionLayer(notnull IEntity ent, int mask)
dGeomCreateSphere
proto native dGeom dGeomCreateSphere(float radius)
Creates sphere geometry.
dJointConeTwistSetLimit
proto native void dJointConeTwistSetLimit(dJoint joint, int limitIndex, float limitValue)
dBodyGetVelocityAt
proto native vector dBodyGetVelocityAt(notnull IEntity body, vector globalpos)
dBodyApplyForce
proto void dBodyApplyForce(notnull IEntity body, vector force)
Applies constant force on a rigidbody (origin)
dGeomCreateCylinder
proto native dGeom dGeomCreateCylinder(float radius, vector extent)
Creates cylinder geometry.
dJointSliderSetDirAngular
proto native void dJointSliderSetDirAngular(dJoint joint, float softness, float restitution, float damping)
dBodyApplyForceAt
proto void dBodyApplyForceAt(notnull IEntity body, vector pos, vector force)
Applies constant force on a position.
dBodyGetGeomInteractionLayer
proto native int dBodyGetGeomInteractionLayer(notnull IEntity ent, int index)
dJointHingeSetAxis
proto native void dJointHingeSetAxis(dJoint joint, vector axis)
dBodyGetNumGeoms
proto native int dBodyGetNumGeoms(notnull IEntity ent)
GetVelocity
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.
dGeomCreateCapsule
proto native dGeom dGeomCreateCapsule(float radius, vector extent)
Creates capsule geometry.
Vector
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
dJointSliderSetLinearLimits
proto native void dJointSliderSetLinearLimits(dJoint joint, float lowerLimit, float upperLimit)
ALWAYS_ACTIVE
@ ALWAYS_ACTIVE
Definition: enphysics.c:89
dGeomDestroy
proto native void dGeomDestroy(dGeom geom)
Destroys geometry.
dJointCreateBallSocket
proto native dJoint dJointCreateBallSocket(notnull IEntity ent1, notnull IEntity ent2, vector point1, vector point2, bool block, float breakThreshold)