载入中...
搜索中...
未找到
Physics.cpp
浏览该文件的文档.
1#include "physics/Physics.h"
2#include "physics/Body.h"
3#include "physics/Body3D.h"
4#include "physics/Joint2D.h"
5#include "physics/Joint3D.h"
11#include "physics/Fixture.h"
12#include "physics/Fluid2D.h"
14#include "physics/Shape3D.h"
15#include "physics/World.h"
16#include "physics/World3D.h"
18
19#include "common/Exception.h"
21
22#include <simplesquirrel/simplesquirrel.hpp>
23
24#include <vector>
25#include <algorithm>
26
27namespace eve::physics {
28
30
32
33void Physics::setMeter(float pixelsPerMeter) {
34 if (pixelsPerMeter <= 0.f)
35 throw Exception("Physics.setMeter: pixelsPerMeter must be > 0");
36 meter_ = pixelsPerMeter;
37}
38
39float Physics::getMeter() const { return meter_; }
40
41World *Physics::newWorld(float gravityX, float gravityY, bool sleep) {
42 return new World(gravityX, gravityY, sleep, meter_);
43}
44
45World3D *Physics::newWorld3D(float gravityX, float gravityY, float gravityZ, bool sleep) {
46 return new World3D(gravityX, gravityY, gravityZ, sleep);
47}
48
50 float originX, float originY, float originZ,
51 float outsideDistance) {
52 return new DistanceField3D(width, height, depth, cellSize, originX, originY, originZ,
53 outsideDistance);
54}
55
56SoftBody3D *Physics::newSoftBody3D(int cols, int rows, int layers, float spacing,
57 float originX, float originY, float originZ) {
58 auto created = SoftBody3D::create(cols, rows, layers, spacing, originX, originY, originZ);
59 if (!created) throw Exception("%s", created.status().describe().c_str());
60 return std::move(created).takeValue().release();
61}
62
66
68
69void Physics::expose(ssq::Table &table) {
70 auto cls = table.addClass(name, Physics::create, false);
71 expose(cls);
72 auto terrainLoadState = table.addClass<TerrainLoadGravityState>("TerrainLoadGravityState");
73 terrainLoadState.addFunc("isMonitoring", &TerrainLoadGravityState::isMonitoring);
74 terrainLoadState.addFunc("isActivationScheduled",
76 terrainLoadState.addFunc("isCompleted", &TerrainLoadGravityState::isCompleted);
77 terrainLoadState.addFunc("getDelayElapsed", &TerrainLoadGravityState::getDelayElapsed);
78 table.addFunc("beginTerrainLoadGravity",
79 [vm = table.getHandle()](TerrainLoadGravityState* state, Body3D* body,
80 bool terrainFound) {
82 beginTerrainLoadGravity(state, body, terrainFound));
83 });
84 table.addFunc("advanceTerrainLoadGravity",
85 [vm = table.getHandle()](TerrainLoadGravityState* state, Body3D* body,
86 bool terrainLoaded, float dt, float delay) {
88 vm, advanceTerrainLoadGravity(state, body, terrainLoaded, dt, delay),
89 [](bool activated) { return eve::Value(activated); });
90 });
91
92 auto world = table.addClass<World>(
93 "World", std::function<World *()>([]() -> World * { return nullptr; }), true);
94 world.addFunc("update", &World::update);
95 world.addFunc("updateFull", &World::updateFull);
96 world.addFunc("setGravity", &World::setGravity);
97 world.addFunc("getGravityX", &World::getGravityX);
98 world.addFunc("getGravityY", &World::getGravityY);
99 world.addFunc("setMeter", &World::setMeter);
100 world.addFunc("getMeter", &World::getMeter);
101 world.addFunc("newBody", &World::newBody);
102 world.addFunc("newDistanceJoint", &World::newDistanceJoint);
103 world.addFunc("newRevoluteJoint", &World::newRevoluteJoint);
104 world.addFunc("newPrismaticJoint", &World::newPrismaticJoint);
105 world.addFunc("newWeldJoint", &World::newWeldJoint);
106 world.addFunc("newWheelJoint", &World::newWheelJoint);
107 world.addFunc("newMotorJoint", &World::newMotorJoint);
108 world.addFunc("newGearJoint", &World::newGearJoint);
109 world.addFunc("newShaft", &World::newShaft);
110 world.addFunc("newRatchet", &World::newRatchet);
111 world.addFunc("newCrankSlider", &World::newCrankSlider);
112 world.addFunc("destroyBody", &World::destroyBody);
113 world.addFunc("destroy", &World::destroy);
114 world.addFunc("drawDebug", &World::drawDebug);
115 world.addFunc("rayCast", &World::rayCast);
116 world.addFunc("hasRayHit", &World::hasRayHit);
117 world.addFunc("getRayHitBodyId", &World::getRayHitBodyId);
118 world.addFunc("getRayHitX", &World::getRayHitX);
119 world.addFunc("getRayHitY", &World::getRayHitY);
120 world.addFunc("getRayHitNormalX", &World::getRayHitNormalX);
121 world.addFunc("getRayHitNormalY", &World::getRayHitNormalY);
122 world.addFunc("getRayHitFraction", &World::getRayHitFraction);
123 world.addFunc("queryAABB", &World::queryAABB);
124 world.addFunc("getQueryCount", &World::getQueryCount);
125 world.addFunc("getQueryBodyId", &World::getQueryBodyId);
126 world.addFunc("getBeginContactCount", &World::getBeginContactCount);
127 world.addFunc("getBeginContactBodyAId", &World::getBeginContactBodyAId);
128 world.addFunc("getBeginContactBodyBId", &World::getBeginContactBodyBId);
129 world.addFunc("getBeginContactFixtureATag", &World::getBeginContactFixtureATag);
130 world.addFunc("getBeginContactFixtureBTag", &World::getBeginContactFixtureBTag);
131 world.addFunc("getEndContactCount", &World::getEndContactCount);
132 world.addFunc("getEndContactBodyAId", &World::getEndContactBodyAId);
133 world.addFunc("getEndContactBodyBId", &World::getEndContactBodyBId);
134 world.addFunc("getEndContactFixtureATag", &World::getEndContactFixtureATag);
135 world.addFunc("getEndContactFixtureBTag", &World::getEndContactFixtureBTag);
136 world.addFunc("getImpactCount", &World::getImpactCount);
137 world.addFunc("getImpactBodyAId", &World::getImpactBodyAId);
138 world.addFunc("getImpactBodyBId", &World::getImpactBodyBId);
139 world.addFunc("getImpactFixtureATag", &World::getImpactFixtureATag);
140 world.addFunc("getImpactFixtureBTag", &World::getImpactFixtureBTag);
141 world.addFunc("getImpactPointX", &World::getImpactPointX);
142 world.addFunc("getImpactPointY", &World::getImpactPointY);
143 world.addFunc("getImpactNormalX", &World::getImpactNormalX);
144 world.addFunc("getImpactNormalY", &World::getImpactNormalY);
145 world.addFunc("getImpactRelativeNormalSpeed", &World::getImpactRelativeNormalSpeed);
146 world.addFunc("getImpactNormalImpulse", &World::getImpactNormalImpulse);
147 world.addFunc("getImpactTangentImpulse", &World::getImpactTangentImpulse);
148 world.addFunc("clearContactEvents", &World::clearContactEvents);
149
150 auto world3 = table.addClass<World3D>(
151 "World3D", std::function<World3D *()>([]() -> World3D * { return nullptr; }), true);
152 world3.addFunc("update", &World3D::update);
153 world3.addFunc("updateFull", &World3D::updateFull);
154 world3.addFunc("setGravity", &World3D::setGravity);
155 world3.addFunc("getGravityX", &World3D::getGravityX);
156 world3.addFunc("getGravityY", &World3D::getGravityY);
157 world3.addFunc("getGravityZ", &World3D::getGravityZ);
158 world3.addFunc("setContinuousCollisionEnabled", &World3D::setContinuousCollisionEnabled);
159 world3.addFunc("isContinuousCollisionEnabled", &World3D::isContinuousCollisionEnabled);
160 world3.addFunc("setRestitutionThreshold", &World3D::setRestitutionThreshold);
161 world3.addFunc("getRestitutionThreshold", &World3D::getRestitutionThreshold);
162 world3.addFunc("setHitEventThreshold", &World3D::setHitEventThreshold);
163 world3.addFunc("getHitEventThreshold", &World3D::getHitEventThreshold);
164 world3.addFunc("setBodyPairCollisionEnabled", &World3D::setBodyPairCollisionEnabled);
165 world3.addFunc("isBodyPairCollisionEnabled", &World3D::isBodyPairCollisionEnabled);
166 world3.addFunc("setShapePairCollisionEnabled", &World3D::setShapePairCollisionEnabled);
167 world3.addFunc("isShapePairCollisionEnabled", &World3D::isShapePairCollisionEnabled);
168 world3.addFunc("setContactTuning", &World3D::setContactTuning);
169 world3.addFunc("getContactHertz", &World3D::getContactHertz);
170 world3.addFunc("getContactDampingRatio", &World3D::getContactDampingRatio);
171 world3.addFunc("getContactPushOutSpeed", &World3D::getContactPushOutSpeed);
172 world3.addFunc("setContactRecycleDistance", &World3D::setContactRecycleDistance);
173 world3.addFunc("getContactRecycleDistance", &World3D::getContactRecycleDistance);
174 world3.addFunc("setMaximumLinearSpeed", &World3D::setMaximumLinearSpeed);
175 world3.addFunc("getMaximumLinearSpeed", &World3D::getMaximumLinearSpeed);
176 world3.addFunc("setWarmStartingEnabled", &World3D::setWarmStartingEnabled);
177 world3.addFunc("isWarmStartingEnabled", &World3D::isWarmStartingEnabled);
178 world3.addFunc("explode", &World3D::explode);
179 world3.addFunc("getExplosionResultCount", &World3D::getExplosionResultCount);
180 world3.addFunc("getExplosionResultBodyId", &World3D::getExplosionResultBodyId);
181 world3.addFunc("getExplosionResultDeltaVelocityX",
183 world3.addFunc("getExplosionResultDeltaVelocityY",
185 world3.addFunc("getExplosionResultDeltaVelocityZ",
187 world3.addFunc("getExplosionResultDeltaAngularVelocityX",
189 world3.addFunc("getExplosionResultDeltaAngularVelocityY",
191 world3.addFunc("getExplosionResultDeltaAngularVelocityZ",
193 world3.addFunc("getBoundsMinX", &World3D::getBoundsMinX);
194 world3.addFunc("getBoundsMinY", &World3D::getBoundsMinY);
195 world3.addFunc("getBoundsMinZ", &World3D::getBoundsMinZ);
196 world3.addFunc("getBoundsMaxX", &World3D::getBoundsMaxX);
197 world3.addFunc("getBoundsMaxY", &World3D::getBoundsMaxY);
198 world3.addFunc("getBoundsMaxZ", &World3D::getBoundsMaxZ);
199 world3.addFunc("getBodyCount", &World3D::getBodyCount);
200 world3.addFunc("getShapeCount", &World3D::getShapeCount);
201 world3.addFunc("getContactCount", &World3D::getContactCount);
202 world3.addFunc("getJointCount", &World3D::getJointCount);
203 world3.addFunc("getIslandCount", &World3D::getIslandCount);
204 world3.addFunc("getAwakeBodyCount", &World3D::getAwakeBodyCount);
205 world3.addFunc("getAwakeContactCount", &World3D::getAwakeContactCount);
206 world3.addFunc("getRecycledContactCount", &World3D::getRecycledContactCount);
207 world3.addFunc("getStaticTreeHeight", &World3D::getStaticTreeHeight);
208 world3.addFunc("getDynamicTreeHeight", &World3D::getDynamicTreeHeight);
209 world3.addFunc("getMemoryByteCount", &World3D::getMemoryByteCount);
210 world3.addFunc("getProfileStepMs", &World3D::getProfileStepMs);
211 world3.addFunc("getProfilePairsMs", &World3D::getProfilePairsMs);
212 world3.addFunc("getProfileCollideMs", &World3D::getProfileCollideMs);
213 world3.addFunc("getProfileSolveMs", &World3D::getProfileSolveMs);
214 world3.addFunc("getProfileBulletsMs", &World3D::getProfileBulletsMs);
215 world3.addFunc("getProfileSensorsMs", &World3D::getProfileSensorsMs);
216 world3.addFunc("newBody", &World3D::newBody);
217 world3.addFunc("newDistanceJoint", &World3D::newDistanceJoint);
218 world3.addFunc("newRevoluteJoint", &World3D::newRevoluteJoint);
219 world3.addFunc("newPrismaticJoint", &World3D::newPrismaticJoint);
220 world3.addFunc("newSphericalJoint", &World3D::newSphericalJoint);
221 world3.addFunc("newWheelJoint", &World3D::newWheelJoint);
222 world3.addFunc("newWeldJoint", &World3D::newWeldJoint);
223 world3.addFunc("newMotorJoint", &World3D::newMotorJoint);
224 world3.addFunc("newParallelJoint", &World3D::newParallelJoint);
225 world3.addFunc("newFilterJoint", &World3D::newFilterJoint);
226 world3.addFunc("newShaft", &World3D::newShaft);
227 world3.addFunc("newRatchet", &World3D::newRatchet);
228 world3.addFunc("newCrankSlider", &World3D::newCrankSlider);
229 world3.addFunc("destroyBody", &World3D::destroyBody);
230 world3.addFunc("destroy", &World3D::destroy);
231 world3.addFunc("rayCast", &World3D::rayCast);
232 world3.addFunc("rayCastAll", &World3D::rayCastAll);
233 world3.addFunc("hasRayHit", &World3D::hasRayHit);
234 world3.addFunc("getRayHitBodyId", &World3D::getRayHitBodyId);
235 world3.addFunc("getRayHitShapeId", &World3D::getRayHitShapeId);
236 world3.addFunc("getRayHitShapeTag", &World3D::getRayHitShapeTag);
237 world3.addFunc("getRayHitMaterialId", &World3D::getRayHitMaterialId);
238 world3.addFunc("getRayHitTriangleIndex", &World3D::getRayHitTriangleIndex);
239 world3.addFunc("getRayHitX", &World3D::getRayHitX);
240 world3.addFunc("getRayHitY", &World3D::getRayHitY);
241 world3.addFunc("getRayHitZ", &World3D::getRayHitZ);
242 world3.addFunc("getRayHitNormalX", &World3D::getRayHitNormalX);
243 world3.addFunc("getRayHitNormalY", &World3D::getRayHitNormalY);
244 world3.addFunc("getRayHitNormalZ", &World3D::getRayHitNormalZ);
245 world3.addFunc("getRayHitFraction", &World3D::getRayHitFraction);
246 world3.addFunc("getRayResultCount", &World3D::getRayResultCount);
247 world3.addFunc("getRayResultBodyId", &World3D::getRayResultBodyId);
248 world3.addFunc("getRayResultShapeId", &World3D::getRayResultShapeId);
249 world3.addFunc("getRayResultShapeTag", &World3D::getRayResultShapeTag);
250 world3.addFunc("getRayResultMaterialId", &World3D::getRayResultMaterialId);
251 world3.addFunc("getRayResultTriangleIndex", &World3D::getRayResultTriangleIndex);
252 world3.addFunc("getRayResultX", &World3D::getRayResultX);
253 world3.addFunc("getRayResultY", &World3D::getRayResultY);
254 world3.addFunc("getRayResultZ", &World3D::getRayResultZ);
255 world3.addFunc("getRayResultNormalX", &World3D::getRayResultNormalX);
256 world3.addFunc("getRayResultNormalY", &World3D::getRayResultNormalY);
257 world3.addFunc("getRayResultNormalZ", &World3D::getRayResultNormalZ);
258 world3.addFunc("getRayResultFraction", &World3D::getRayResultFraction);
259 world3.addFunc("queryAABB", &World3D::queryAABB);
260 world3.addFunc("querySphere", &World3D::querySphere);
261 world3.addFunc("queryCapsule", &World3D::queryCapsule);
262 world3.addFunc("queryBox", &World3D::queryBox);
263 world3.addFunc("castSphere", &World3D::castSphere);
264 world3.addFunc("castSphereAll", &World3D::castSphereAll);
265 world3.addFunc("castCapsule", &World3D::castCapsule);
266 world3.addFunc("castCapsuleAll", &World3D::castCapsuleAll);
267 world3.addFunc("castBox", &World3D::castBox);
268 world3.addFunc("castBoxAll", &World3D::castBoxAll);
269 world3.addFunc("closestPoint", &World3D::closestPoint);
270 world3.addFunc("hasClosestPoint", &World3D::hasClosestPoint);
271 world3.addFunc("getClosestBodyId", &World3D::getClosestBodyId);
272 world3.addFunc("getClosestShapeId", &World3D::getClosestShapeId);
273 world3.addFunc("getClosestShapeTag", &World3D::getClosestShapeTag);
274 world3.addFunc("getClosestX", &World3D::getClosestX);
275 world3.addFunc("getClosestY", &World3D::getClosestY);
276 world3.addFunc("getClosestZ", &World3D::getClosestZ);
277 world3.addFunc("getClosestNormalX", &World3D::getClosestNormalX);
278 world3.addFunc("getClosestNormalY", &World3D::getClosestNormalY);
279 world3.addFunc("getClosestNormalZ", &World3D::getClosestNormalZ);
280 world3.addFunc("getClosestDistance", &World3D::getClosestDistance);
281 world3.addFunc("hasShapeCastHit", &World3D::hasShapeCastHit);
282 world3.addFunc("getShapeCastBodyId", &World3D::getShapeCastBodyId);
283 world3.addFunc("getShapeCastShapeId", &World3D::getShapeCastShapeId);
284 world3.addFunc("getShapeCastShapeTag", &World3D::getShapeCastShapeTag);
285 world3.addFunc("getShapeCastMaterialId", &World3D::getShapeCastMaterialId);
286 world3.addFunc("getShapeCastTriangleIndex", &World3D::getShapeCastTriangleIndex);
287 world3.addFunc("getShapeCastX", &World3D::getShapeCastX);
288 world3.addFunc("getShapeCastY", &World3D::getShapeCastY);
289 world3.addFunc("getShapeCastZ", &World3D::getShapeCastZ);
290 world3.addFunc("getShapeCastNormalX", &World3D::getShapeCastNormalX);
291 world3.addFunc("getShapeCastNormalY", &World3D::getShapeCastNormalY);
292 world3.addFunc("getShapeCastNormalZ", &World3D::getShapeCastNormalZ);
293 world3.addFunc("getShapeCastFraction", &World3D::getShapeCastFraction);
294 world3.addFunc("getShapeCastResultCount", &World3D::getShapeCastResultCount);
295 world3.addFunc("getShapeCastResultBodyId", &World3D::getShapeCastResultBodyId);
296 world3.addFunc("getShapeCastResultShapeId", &World3D::getShapeCastResultShapeId);
297 world3.addFunc("getShapeCastResultShapeTag", &World3D::getShapeCastResultShapeTag);
298 world3.addFunc("getShapeCastResultMaterialId", &World3D::getShapeCastResultMaterialId);
299 world3.addFunc("getShapeCastResultTriangleIndex",
301 world3.addFunc("getShapeCastResultX", &World3D::getShapeCastResultX);
302 world3.addFunc("getShapeCastResultY", &World3D::getShapeCastResultY);
303 world3.addFunc("getShapeCastResultZ", &World3D::getShapeCastResultZ);
304 world3.addFunc("getShapeCastResultNormalX", &World3D::getShapeCastResultNormalX);
305 world3.addFunc("getShapeCastResultNormalY", &World3D::getShapeCastResultNormalY);
306 world3.addFunc("getShapeCastResultNormalZ", &World3D::getShapeCastResultNormalZ);
307 world3.addFunc("getShapeCastResultFraction", &World3D::getShapeCastResultFraction);
308 world3.addFunc("moveCapsule", &World3D::moveCapsule);
309 world3.addFunc("getMoverDeltaX", &World3D::getMoverDeltaX);
310 world3.addFunc("getMoverDeltaY", &World3D::getMoverDeltaY);
311 world3.addFunc("getMoverDeltaZ", &World3D::getMoverDeltaZ);
312 world3.addFunc("getMoverNormalX", &World3D::getMoverNormalX);
313 world3.addFunc("getMoverNormalY", &World3D::getMoverNormalY);
314 world3.addFunc("getMoverNormalZ", &World3D::getMoverNormalZ);
315 world3.addFunc("getMoverPlaneCount", &World3D::getMoverPlaneCount);
316 world3.addFunc("getMoverIterations", &World3D::getMoverIterations);
317 world3.addFunc("setMoverUp", &World3D::setMoverUp);
318 world3.addFunc("setMoverSlopeLimit", &World3D::setMoverSlopeLimit);
319 world3.addFunc("isMoverGrounded", &World3D::isMoverGrounded);
320 world3.addFunc("getMoverGroundDot", &World3D::getMoverGroundDot);
321 world3.addFunc("getQueryCount", &World3D::getQueryCount);
322 world3.addFunc("getQueryBodyId", &World3D::getQueryBodyId);
323 world3.addFunc("getQueryShapeCount", &World3D::getQueryShapeCount);
324 world3.addFunc("getQueryShapeId", &World3D::getQueryShapeId);
325 world3.addFunc("getQueryShapeTag", &World3D::getQueryShapeTag);
326 world3.addFunc("getBeginContactCount", &World3D::getBeginContactCount);
327 world3.addFunc("getBeginContactBodyAId", &World3D::getBeginContactBodyAId);
328 world3.addFunc("getBeginContactBodyBId", &World3D::getBeginContactBodyBId);
329 world3.addFunc("getBeginContactShapeAId", &World3D::getBeginContactShapeAId);
330 world3.addFunc("getBeginContactShapeBId", &World3D::getBeginContactShapeBId);
331 world3.addFunc("getBeginContactShapeATag", &World3D::getBeginContactShapeATag);
332 world3.addFunc("getBeginContactShapeBTag", &World3D::getBeginContactShapeBTag);
333 world3.addFunc("getEndContactCount", &World3D::getEndContactCount);
334 world3.addFunc("getEndContactBodyAId", &World3D::getEndContactBodyAId);
335 world3.addFunc("getEndContactBodyBId", &World3D::getEndContactBodyBId);
336 world3.addFunc("getEndContactShapeAId", &World3D::getEndContactShapeAId);
337 world3.addFunc("getEndContactShapeBId", &World3D::getEndContactShapeBId);
338 world3.addFunc("getEndContactShapeATag", &World3D::getEndContactShapeATag);
339 world3.addFunc("getEndContactShapeBTag", &World3D::getEndContactShapeBTag);
340 world3.addFunc("getBeginTriggerCount", &World3D::getBeginTriggerCount);
341 world3.addFunc("getBeginTriggerSensorBodyId", &World3D::getBeginTriggerSensorBodyId);
342 world3.addFunc("getBeginTriggerVisitorBodyId", &World3D::getBeginTriggerVisitorBodyId);
343 world3.addFunc("getBeginTriggerSensorShapeId", &World3D::getBeginTriggerSensorShapeId);
344 world3.addFunc("getBeginTriggerVisitorShapeId", &World3D::getBeginTriggerVisitorShapeId);
345 world3.addFunc("getBeginTriggerSensorShapeTag", &World3D::getBeginTriggerSensorShapeTag);
346 world3.addFunc("getBeginTriggerVisitorShapeTag", &World3D::getBeginTriggerVisitorShapeTag);
347 world3.addFunc("getEndTriggerCount", &World3D::getEndTriggerCount);
348 world3.addFunc("getEndTriggerSensorBodyId", &World3D::getEndTriggerSensorBodyId);
349 world3.addFunc("getEndTriggerVisitorBodyId", &World3D::getEndTriggerVisitorBodyId);
350 world3.addFunc("getEndTriggerSensorShapeId", &World3D::getEndTriggerSensorShapeId);
351 world3.addFunc("getEndTriggerVisitorShapeId", &World3D::getEndTriggerVisitorShapeId);
352 world3.addFunc("getEndTriggerSensorShapeTag", &World3D::getEndTriggerSensorShapeTag);
353 world3.addFunc("getEndTriggerVisitorShapeTag", &World3D::getEndTriggerVisitorShapeTag);
354 world3.addFunc("clearContactEvents", &World3D::clearContactEvents);
355 world3.addFunc("queryBodyContacts", &World3D::queryBodyContacts);
356 world3.addFunc("getContactPointCount", &World3D::getContactPointCount);
357 world3.addFunc("getContactPointShapeId", &World3D::getContactPointShapeId);
358 world3.addFunc("getContactPointShapeTag", &World3D::getContactPointShapeTag);
359 world3.addFunc("getContactPointOtherBodyId", &World3D::getContactPointOtherBodyId);
360 world3.addFunc("getContactPointOtherShapeId", &World3D::getContactPointOtherShapeId);
361 world3.addFunc("getContactPointOtherShapeTag", &World3D::getContactPointOtherShapeTag);
362 world3.addFunc("getContactPointX", &World3D::getContactPointX);
363 world3.addFunc("getContactPointY", &World3D::getContactPointY);
364 world3.addFunc("getContactPointZ", &World3D::getContactPointZ);
365 world3.addFunc("getContactPointNormalX", &World3D::getContactPointNormalX);
366 world3.addFunc("getContactPointNormalY", &World3D::getContactPointNormalY);
367 world3.addFunc("getContactPointNormalZ", &World3D::getContactPointNormalZ);
368 world3.addFunc("getContactPointSeparation", &World3D::getContactPointSeparation);
369 world3.addFunc("getContactPointNormalImpulse", &World3D::getContactPointNormalImpulse);
370 world3.addFunc("getContactPointTotalNormalImpulse", &World3D::getContactPointTotalNormalImpulse);
371 world3.addFunc("getContactPointNormalVelocity", &World3D::getContactPointNormalVelocity);
372 world3.addFunc("isContactPointPersisted", &World3D::isContactPointPersisted);
373 world3.addFunc("getHitCount", &World3D::getHitCount);
374 world3.addFunc("getHitBodyAId", &World3D::getHitBodyAId);
375 world3.addFunc("getHitBodyBId", &World3D::getHitBodyBId);
376 world3.addFunc("getHitShapeAId", &World3D::getHitShapeAId);
377 world3.addFunc("getHitShapeBId", &World3D::getHitShapeBId);
378 world3.addFunc("getHitShapeATag", &World3D::getHitShapeATag);
379 world3.addFunc("getHitShapeBTag", &World3D::getHitShapeBTag);
380 world3.addFunc("getHitPointX", &World3D::getHitPointX);
381 world3.addFunc("getHitPointY", &World3D::getHitPointY);
382 world3.addFunc("getHitPointZ", &World3D::getHitPointZ);
383 world3.addFunc("getHitNormalX", &World3D::getHitNormalX);
384 world3.addFunc("getHitNormalY", &World3D::getHitNormalY);
385 world3.addFunc("getHitNormalZ", &World3D::getHitNormalZ);
386 world3.addFunc("getHitApproachSpeed", &World3D::getHitApproachSpeed);
387 world3.addFunc("getHitNormalImpulse", &World3D::getHitNormalImpulse);
388 world3.addFunc("getJointStressCount", &World3D::getJointStressCount);
389 world3.addFunc("getJointStressJointId", &World3D::getJointStressJointId);
390 world3.addFunc("getJointStressBodyAId", &World3D::getJointStressBodyAId);
391 world3.addFunc("getJointStressBodyBId", &World3D::getJointStressBodyBId);
392 world3.addFunc("getJointStressKind", &World3D::getJointStressKind);
393 world3.addFunc("getJointStressForceX", &World3D::getJointStressForceX);
394 world3.addFunc("getJointStressForceY", &World3D::getJointStressForceY);
395 world3.addFunc("getJointStressForceZ", &World3D::getJointStressForceZ);
396 world3.addFunc("getJointStressTorqueX", &World3D::getJointStressTorqueX);
397 world3.addFunc("getJointStressTorqueY", &World3D::getJointStressTorqueY);
398 world3.addFunc("getJointStressTorqueZ", &World3D::getJointStressTorqueZ);
399 world3.addFunc("setQueryFilter", &World3D::setQueryFilter);
400 world3.addFunc("resetQueryFilter", &World3D::resetQueryFilter);
401 world3.addFunc("getQueryCategoryBits", &World3D::getQueryCategoryBits);
402 world3.addFunc("getQueryMaskBits", &World3D::getQueryMaskBits);
403 world3.addFunc("setQueryIgnoredBodyId", &World3D::setQueryIgnoredBodyId);
404 world3.addFunc("setQueryIgnoredShapeId", &World3D::setQueryIgnoredShapeId);
405 world3.addFunc("getQueryIgnoredBodyId", &World3D::getQueryIgnoredBodyId);
406 world3.addFunc("getQueryIgnoredShapeId", &World3D::getQueryIgnoredShapeId);
407 world3.addFunc("clearQueryIgnores", &World3D::clearQueryIgnores);
408
409 auto sdf = table.addClass<DistanceField3D>(
410 "DistanceField3D", std::function<DistanceField3D *()>([]() -> DistanceField3D * {
411 return nullptr;
412 }), true);
413 sdf.addFunc("setDistances", [](DistanceField3D *field, ssq::Array values) {
414 std::vector<float> distances;
415 distances.reserve(values.size());
416 const size_t count = values.size();
417 for (size_t i = 0; i < count; ++i) distances.push_back(values.get<float>(i));
418 field->setDistances(distances);
419 });
420 sdf.addFunc("setDistanceRegion",
421 [](DistanceField3D *field, int x, int y, int z, int width, int height, int depth,
422 ssq::Array values) {
423 std::vector<float> distances;
424 const size_t count = values.size();
425 distances.reserve(count);
426 for (size_t i = 0; i < count; ++i)
427 distances.push_back(values.get<float>(i));
428 field->setDistanceRegion(x, y, z, width, height, depth, distances);
429 });
430 sdf.addFunc("fill", &DistanceField3D::fill);
431 sdf.addFunc("fillRegion", &DistanceField3D::fillRegion);
432 sdf.addFunc("setDistance", &DistanceField3D::setDistance);
433 sdf.addFunc("getDistance", &DistanceField3D::getDistance);
434 sdf.addFunc("sample", &DistanceField3D::sample);
435 sdf.addFunc("getWidth", &DistanceField3D::getWidth);
436 sdf.addFunc("getHeight", &DistanceField3D::getHeight);
437 sdf.addFunc("getDepth", &DistanceField3D::getDepth);
438 sdf.addFunc("getSampleCount", &DistanceField3D::getSampleCount);
439 sdf.addFunc("getCellSize", &DistanceField3D::getCellSize);
440 sdf.addFunc("getOriginX", &DistanceField3D::getOriginX);
441 sdf.addFunc("getOriginY", &DistanceField3D::getOriginY);
442 sdf.addFunc("getOriginZ", &DistanceField3D::getOriginZ);
443 sdf.addFunc("getOutsideDistance", &DistanceField3D::getOutsideDistance);
444 sdf.addFunc("getRevision", &DistanceField3D::getRevision);
445 sdf.addFunc("sampleNormal", &DistanceField3D::sampleNormal);
446 sdf.addFunc("getNormalX", &DistanceField3D::getNormalX);
447 sdf.addFunc("getNormalY", &DistanceField3D::getNormalY);
448 sdf.addFunc("getNormalZ", &DistanceField3D::getNormalZ);
449 sdf.addFunc("checkSphere", &DistanceField3D::checkSphere);
450 sdf.addFunc("checkCapsule", &DistanceField3D::checkCapsule);
451 sdf.addFunc("castSphere", &DistanceField3D::castSphere);
452 sdf.addFunc("castCapsule", &DistanceField3D::castCapsule);
453 sdf.addFunc("moveCapsule", &DistanceField3D::moveCapsule);
454 sdf.addFunc("setMoverUp", &DistanceField3D::setMoverUp);
455 sdf.addFunc("setMoverSlopeLimit", &DistanceField3D::setMoverSlopeLimit);
456 sdf.addFunc("setMoverSkinWidth", &DistanceField3D::setMoverSkinWidth);
457 sdf.addFunc("getMoverSkinWidth", &DistanceField3D::getMoverSkinWidth);
458 sdf.addFunc("setMoverGroundSnap", &DistanceField3D::setMoverGroundSnap);
459 sdf.addFunc("getMoverGroundSnap", &DistanceField3D::getMoverGroundSnap);
460 sdf.addFunc("setMoverStepHeight", &DistanceField3D::setMoverStepHeight);
461 sdf.addFunc("getMoverStepHeight", &DistanceField3D::getMoverStepHeight);
462 sdf.addFunc("getCollisionDistance", &DistanceField3D::getCollisionDistance);
463 sdf.addFunc("getCollisionX", &DistanceField3D::getCollisionX);
464 sdf.addFunc("getCollisionY", &DistanceField3D::getCollisionY);
465 sdf.addFunc("getCollisionZ", &DistanceField3D::getCollisionZ);
466 sdf.addFunc("getSurfaceX", &DistanceField3D::getSurfaceX);
467 sdf.addFunc("getSurfaceY", &DistanceField3D::getSurfaceY);
468 sdf.addFunc("getSurfaceZ", &DistanceField3D::getSurfaceZ);
469 sdf.addFunc("getShapeContactX", &DistanceField3D::getShapeContactX);
470 sdf.addFunc("getShapeContactY", &DistanceField3D::getShapeContactY);
471 sdf.addFunc("getShapeContactZ", &DistanceField3D::getShapeContactZ);
472 sdf.addFunc("getPenetrationDepth", &DistanceField3D::getPenetrationDepth);
473 sdf.addFunc("getCastFraction", &DistanceField3D::getCastFraction);
474 sdf.addFunc("getCastDistance", &DistanceField3D::getCastDistance);
475 sdf.addFunc("didCastStartInside", &DistanceField3D::didCastStartInside);
476 sdf.addFunc("getMoverDeltaX", &DistanceField3D::getMoverDeltaX);
477 sdf.addFunc("getMoverDeltaY", &DistanceField3D::getMoverDeltaY);
478 sdf.addFunc("getMoverDeltaZ", &DistanceField3D::getMoverDeltaZ);
479 sdf.addFunc("getMoverNormalX", &DistanceField3D::getMoverNormalX);
480 sdf.addFunc("getMoverNormalY", &DistanceField3D::getMoverNormalY);
481 sdf.addFunc("getMoverNormalZ", &DistanceField3D::getMoverNormalZ);
482 sdf.addFunc("getMoverIterations", &DistanceField3D::getMoverIterations);
483 sdf.addFunc("isMoverGrounded", &DistanceField3D::isMoverGrounded);
484 sdf.addFunc("getMoverGroundDot", &DistanceField3D::getMoverGroundDot);
485 sdf.addFunc("didMoverHitWall", &DistanceField3D::didMoverHitWall);
486
487 auto body = table.addClass<Body>(
488 "Body", std::function<Body *()>([]() -> Body * { return nullptr; }), true);
489 body.addFunc("getId", &Body::getId);
490 body.addFunc("setPosition", &Body::setPosition);
491 body.addFunc("getX", &Body::getX);
492 body.addFunc("getY", &Body::getY);
493 body.addFunc("setAngle", &Body::setAngle);
494 body.addFunc("getAngle", &Body::getAngle);
495 body.addFunc("setLinearVelocity", &Body::setLinearVelocity);
496 body.addFunc("getLinearVelocityX", &Body::getLinearVelocityX);
497 body.addFunc("getLinearVelocityY", &Body::getLinearVelocityY);
498 body.addFunc("getLinearSpeed", &Body::getLinearSpeed);
499 body.addFunc("getMass", &Body::getMass);
500 body.addFunc("getWorldCenterX", &Body::getWorldCenterX);
501 body.addFunc("getWorldCenterY", &Body::getWorldCenterY);
502 body.addFunc("setAngularVelocity", &Body::setAngularVelocity);
503 body.addFunc("getAngularVelocity", &Body::getAngularVelocity);
504 body.addFunc("applyForce", &Body::applyForce);
505 body.addFunc("applyForceAt", &Body::applyForceAt);
506 body.addFunc("applyLinearImpulse", &Body::applyLinearImpulse);
507 body.addFunc("applyAngularImpulse", &Body::applyAngularImpulse);
508 body.addFunc("setType", &Body::setType);
509 body.addFunc("getType", &Body::getType);
510 body.addFunc("setFixedRotation", &Body::setFixedRotation);
511 body.addFunc("isFixedRotation", &Body::isFixedRotation);
512 body.addFunc("setActive", &Body::setActive);
513 body.addFunc("isActive", &Body::isActive);
514 body.addFunc("setBullet", &Body::setBullet);
515 body.addFunc("isBullet", &Body::isBullet);
516 body.addFunc("setAwake", &Body::setAwake);
517 body.addFunc("isAwake", &Body::isAwake);
518 body.addFunc("newRectangleFixture", &Body::newRectangleFixture);
519 body.addFunc("newRectangleFixtureAt", &Body::newRectangleFixtureAt);
520 body.addFunc("newCircleFixture", &Body::newCircleFixture);
521 body.addFunc("destroy", &Body::destroy);
522
523 auto joint2 = table.addClass<Joint2D>(
524 "Joint2D", std::function<Joint2D *()>([]() -> Joint2D * { return nullptr; }), true);
525 joint2.addFunc("getId", &Joint2D::getId);
526 joint2.addFunc("getKind", &Joint2D::getKind);
527 joint2.addFunc("getBodyAId", &Joint2D::getBodyAId);
528 joint2.addFunc("getBodyBId", &Joint2D::getBodyBId);
529 joint2.addFunc("setCollideConnected", &Joint2D::setCollideConnected);
530 joint2.addFunc("getCollideConnected", &Joint2D::getCollideConnected);
531 joint2.addFunc("setDistanceLength", &Joint2D::setDistanceLength);
532 joint2.addFunc("getDistanceLength", &Joint2D::getDistanceLength);
533 joint2.addFunc("setDistanceSpring", &Joint2D::setDistanceSpring);
534 joint2.addFunc("getDistanceFrequency", &Joint2D::getDistanceFrequency);
535 joint2.addFunc("getDistanceDampingRatio", &Joint2D::getDistanceDampingRatio);
536 joint2.addFunc("setRevoluteLimits", &Joint2D::setRevoluteLimits);
537 joint2.addFunc("setRevoluteMotor", &Joint2D::setRevoluteMotor);
538 joint2.addFunc("getRevoluteAngle", &Joint2D::getRevoluteAngle);
539 joint2.addFunc("getRevoluteSpeed", &Joint2D::getRevoluteSpeed);
540 joint2.addFunc("getRevoluteMotorTorque", &Joint2D::getRevoluteMotorTorque);
541 joint2.addFunc("setPrismaticLimits", &Joint2D::setPrismaticLimits);
542 joint2.addFunc("setPrismaticMotor", &Joint2D::setPrismaticMotor);
543 joint2.addFunc("getPrismaticTranslation", &Joint2D::getPrismaticTranslation);
544 joint2.addFunc("getPrismaticSpeed", &Joint2D::getPrismaticSpeed);
545 joint2.addFunc("setWeldSpring", &Joint2D::setWeldSpring);
546 joint2.addFunc("getWeldFrequency", &Joint2D::getWeldFrequency);
547 joint2.addFunc("getWeldDampingRatio", &Joint2D::getWeldDampingRatio);
548 joint2.addFunc("setWheelSpring", &Joint2D::setWheelSpring);
549 joint2.addFunc("setWheelMotor", &Joint2D::setWheelMotor);
550 joint2.addFunc("getWheelTranslation", &Joint2D::getWheelTranslation);
551 joint2.addFunc("getWheelSpeed", &Joint2D::getWheelSpeed);
552 joint2.addFunc("setMotorLinearOffset", &Joint2D::setMotorLinearOffset);
553 joint2.addFunc("setMotorAngularOffset", &Joint2D::setMotorAngularOffset);
554 joint2.addFunc("setMotorLimits", &Joint2D::setMotorLimits);
555 joint2.addFunc("getMotorLinearOffsetX", &Joint2D::getMotorLinearOffsetX);
556 joint2.addFunc("getMotorLinearOffsetY", &Joint2D::getMotorLinearOffsetY);
557 joint2.addFunc("getMotorAngularOffset", &Joint2D::getMotorAngularOffset);
558 joint2.addFunc("setGearRatio", &Joint2D::setGearRatio);
559 joint2.addFunc("getGearRatio", &Joint2D::getGearRatio);
560 joint2.addFunc("getGearJoint1", &Joint2D::getGearJoint1);
561 joint2.addFunc("getGearJoint2", &Joint2D::getGearJoint2);
562 joint2.addFunc("destroy", &Joint2D::destroy);
563 joint2.addFunc("isValid", &Joint2D::isValid);
564
565 auto mechanism2 = table.addClass<Mechanism2D>(
566 "Mechanism2D", std::function<Mechanism2D *()>([]() -> Mechanism2D * { return nullptr; }),
567 true);
568 mechanism2.addFunc("getId", &Mechanism2D::getId);
569 mechanism2.addFunc("getKind", &Mechanism2D::getKind);
570 mechanism2.addFunc("isValid", &Mechanism2D::isValid);
571 mechanism2.addFunc("getDriveJoint", &Mechanism2D::getDriveJoint);
572 mechanism2.addFunc("getCrankPinJoint", &Mechanism2D::getCrankPinJoint);
573 mechanism2.addFunc("getSliderPinJoint", &Mechanism2D::getSliderPinJoint);
574 mechanism2.addFunc("getSliderJoint", &Mechanism2D::getSliderJoint);
575 mechanism2.addFunc("getDriveAngle", &Mechanism2D::getDriveAngle);
576 mechanism2.addFunc("getSliderTranslation", &Mechanism2D::getSliderTranslation);
577 mechanism2.addFunc("getSpinSpeed", &Mechanism2D::getSpinSpeed);
578 mechanism2.addFunc("setDrive", &Mechanism2D::setDrive);
579 mechanism2.addFunc("clearDrive", &Mechanism2D::clearDrive);
580 mechanism2.addFunc("isDriveEnabled", &Mechanism2D::isDriveEnabled);
581 mechanism2.addFunc("setRatchetDirection", &Mechanism2D::setRatchetDirection);
582 mechanism2.addFunc("getRatchetDirection", &Mechanism2D::getRatchetDirection);
583 mechanism2.addFunc("setRatchetEngagementTorque", &Mechanism2D::setRatchetEngagementTorque);
584 mechanism2.addFunc("getRatchetEngagementTorque", &Mechanism2D::getRatchetEngagementTorque);
585 mechanism2.addFunc("destroy", &Mechanism2D::destroy);
586
587 auto body3 = table.addClass<Body3D>(
588 "Body3D", std::function<Body3D *()>([]() -> Body3D * { return nullptr; }), true);
589 body3.addFunc("getId", &Body3D::getId);
590 body3.addFunc("setPosition", &Body3D::setPosition);
591 body3.addFunc("getX", &Body3D::getX);
592 body3.addFunc("getY", &Body3D::getY);
593 body3.addFunc("getZ", &Body3D::getZ);
594 body3.addFunc("setRotation", &Body3D::setRotation);
595 body3.addFunc("getRotX", &Body3D::getRotX);
596 body3.addFunc("getRotY", &Body3D::getRotY);
597 body3.addFunc("getRotZ", &Body3D::getRotZ);
598 body3.addFunc("getRotW", &Body3D::getRotW);
599 body3.addFunc("setLinearVelocity", &Body3D::setLinearVelocity);
600 body3.addFunc("getLinearVelocityX", &Body3D::getLinearVelocityX);
601 body3.addFunc("getLinearVelocityY", &Body3D::getLinearVelocityY);
602 body3.addFunc("getLinearVelocityZ", &Body3D::getLinearVelocityZ);
603 body3.addFunc("getMass", &Body3D::getMass);
604 body3.addFunc("setAngularVelocity", &Body3D::setAngularVelocity);
605 body3.addFunc("getAngularVelocityX", &Body3D::getAngularVelocityX);
606 body3.addFunc("getAngularVelocityY", &Body3D::getAngularVelocityY);
607 body3.addFunc("getAngularVelocityZ", &Body3D::getAngularVelocityZ);
608 body3.addFunc("localToWorldPoint", &Body3D::localToWorldPoint);
609 body3.addFunc("worldToLocalPoint", &Body3D::worldToLocalPoint);
610 body3.addFunc("localToWorldVector", &Body3D::localToWorldVector);
611 body3.addFunc("worldToLocalVector", &Body3D::worldToLocalVector);
612 body3.addFunc("getLocalPointVelocity", &Body3D::getLocalPointVelocity);
613 body3.addFunc("getWorldPointVelocity", &Body3D::getWorldPointVelocity);
614 body3.addFunc("applyForce", &Body3D::applyForce);
615 body3.addFunc("applyForceAt", &Body3D::applyForceAt);
616 body3.addFunc("applyTorque", &Body3D::applyTorque);
617 body3.addFunc("applyLinearImpulse", &Body3D::applyLinearImpulse);
618 body3.addFunc("applyLinearImpulseAt", &Body3D::applyLinearImpulseAt);
619 body3.addFunc("applyAngularImpulse", &Body3D::applyAngularImpulse);
620 body3.addFunc("applyLocalForce", &Body3D::applyLocalForce);
621 body3.addFunc("applyLocalForceToCenter", &Body3D::applyLocalForceToCenter);
622 body3.addFunc("applyLocalTorque", &Body3D::applyLocalTorque);
623 body3.addFunc("applyLocalLinearImpulse", &Body3D::applyLocalLinearImpulse);
624 body3.addFunc("applyLocalLinearImpulseToCenter", &Body3D::applyLocalLinearImpulseToCenter);
625 body3.addFunc("applyLocalAngularImpulse", &Body3D::applyLocalAngularImpulse);
626 body3.addFunc("setTargetTransform", &Body3D::setTargetTransform);
627 body3.addFunc("setLinearDamping", &Body3D::setLinearDamping);
628 body3.addFunc("getLinearDamping", &Body3D::getLinearDamping);
629 body3.addFunc("setAngularDamping", &Body3D::setAngularDamping);
630 body3.addFunc("getAngularDamping", &Body3D::getAngularDamping);
631 body3.addFunc("setGravityScale", &Body3D::setGravityScale);
632 body3.addFunc("getGravityScale", &Body3D::getGravityScale);
633 body3.addFunc("setSleepEnabled", &Body3D::setSleepEnabled);
634 body3.addFunc("isSleepEnabled", &Body3D::isSleepEnabled);
635 body3.addFunc("setSleepThreshold", &Body3D::setSleepThreshold);
636 body3.addFunc("getSleepThreshold", &Body3D::getSleepThreshold);
637 body3.addFunc("setMotionLocks", &Body3D::setMotionLocks);
638 body3.addFunc("isLinearXLocked", &Body3D::isLinearXLocked);
639 body3.addFunc("isLinearYLocked", &Body3D::isLinearYLocked);
640 body3.addFunc("isLinearZLocked", &Body3D::isLinearZLocked);
641 body3.addFunc("isAngularXLocked", &Body3D::isAngularXLocked);
642 body3.addFunc("isAngularYLocked", &Body3D::isAngularYLocked);
643 body3.addFunc("isAngularZLocked", &Body3D::isAngularZLocked);
644 body3.addFunc("getMass", &Body3D::getMass);
645 body3.addFunc("setMassProperties", &Body3D::setMassProperties);
646 body3.addFunc("resetMassProperties", &Body3D::resetMassProperties);
647 body3.addFunc("getInertiaXX", &Body3D::getInertiaXX);
648 body3.addFunc("getInertiaYY", &Body3D::getInertiaYY);
649 body3.addFunc("getInertiaZZ", &Body3D::getInertiaZZ);
650 body3.addFunc("getInertiaXY", &Body3D::getInertiaXY);
651 body3.addFunc("getInertiaXZ", &Body3D::getInertiaXZ);
652 body3.addFunc("getInertiaYZ", &Body3D::getInertiaYZ);
653 body3.addFunc("getLocalCenterX", &Body3D::getLocalCenterX);
654 body3.addFunc("getLocalCenterY", &Body3D::getLocalCenterY);
655 body3.addFunc("getLocalCenterZ", &Body3D::getLocalCenterZ);
656 body3.addFunc("getWorldCenterX", &Body3D::getWorldCenterX);
657 body3.addFunc("getWorldCenterY", &Body3D::getWorldCenterY);
658 body3.addFunc("getWorldCenterZ", &Body3D::getWorldCenterZ);
659 body3.addFunc("setType", &Body3D::setType);
660 body3.addFunc("getType", &Body3D::getType);
661 body3.addFunc("setFixedRotation", &Body3D::setFixedRotation);
662 body3.addFunc("isFixedRotation", &Body3D::isFixedRotation);
663 body3.addFunc("setActive", &Body3D::setActive);
664 body3.addFunc("isActive", &Body3D::isActive);
665 body3.addFunc("setBullet", &Body3D::setBullet);
666 body3.addFunc("isBullet", &Body3D::isBullet);
667 body3.addFunc("setAwake", &Body3D::setAwake);
668 body3.addFunc("isAwake", &Body3D::isAwake);
669 body3.addFunc("newBoxShape", &Body3D::newBoxShape);
670 body3.addFunc("newSphereShape", &Body3D::newSphereShape);
671 body3.addFunc("newCapsuleShape", &Body3D::newCapsuleShape);
672 body3.addFunc("newConvexHullShape", [](Body3D *body, ssq::Array values, int maxVertices) {
673 std::vector<float> vertices;
674 vertices.reserve(values.size());
675 for (size_t i = 0; i < values.size(); ++i) vertices.push_back(values.get<float>(i));
676 return body->newConvexHullShape(vertices, maxVertices);
677 });
678 body3.addFunc("newTriangleMeshShape",
679 [](Body3D *body, ssq::Array vertexValues, ssq::Array indexValues) {
680 std::vector<float> vertices;
681 std::vector<int32_t> indices;
682 vertices.reserve(vertexValues.size());
683 indices.reserve(indexValues.size());
684 for (size_t i = 0; i < vertexValues.size(); ++i)
685 vertices.push_back(vertexValues.get<float>(i));
686 for (size_t i = 0; i < indexValues.size(); ++i)
687 indices.push_back(indexValues.get<int32_t>(i));
688 return body->newTriangleMeshShape(vertices, indices);
689 });
690 body3.addFunc(
691 "newTriangleMeshShapeFull",
692 [](Body3D *body, ssq::Array vertexValues, ssq::Array indexValues, bool weldVertices,
693 float weldTolerance, bool identifyEdges, bool useMedianSplit) {
694 std::vector<float> vertices;
695 std::vector<int32_t> indices;
696 vertices.reserve(vertexValues.size());
697 indices.reserve(indexValues.size());
698 for (size_t i = 0; i < vertexValues.size(); ++i)
699 vertices.push_back(vertexValues.get<float>(i));
700 for (size_t i = 0; i < indexValues.size(); ++i)
701 indices.push_back(indexValues.get<int32_t>(i));
702 return body->newTriangleMeshShape(vertices, indices, weldVertices, weldTolerance,
703 identifyEdges, useMedianSplit);
704 });
705 body3.addFunc("newHeightFieldShape",
706 [](Body3D *body, int countX, int countZ, float cellSizeX, float cellSizeZ,
707 ssq::Array values) {
708 std::vector<float> heights;
709 heights.reserve(values.size());
710 for (size_t i = 0; i < values.size(); ++i)
711 heights.push_back(values.get<float>(i));
712 if (heights.empty())
713 throw eve::Exception("Body3D.newHeightFieldShape: heights is empty");
714 const auto range = std::minmax_element(heights.begin(), heights.end());
715 return body->newHeightFieldShape(countX, countZ, cellSizeX, cellSizeZ,
716 heights, *range.first, *range.second);
717 });
718 body3.addFunc(
719 "newHeightFieldShapeFull",
720 [](Body3D *body, int countX, int countZ, float cellSizeX, float cellSizeZ,
721 ssq::Array values, float globalMin, float globalMax, bool clockwiseWinding) {
722 std::vector<float> heights;
723 heights.reserve(values.size());
724 for (size_t i = 0; i < values.size(); ++i)
725 heights.push_back(values.get<float>(i));
726 return body->newHeightFieldShape(countX, countZ, cellSizeX, cellSizeZ, heights,
727 globalMin, globalMax, clockwiseWinding);
728 });
729 body3.addFunc("destroy", &Body3D::destroy);
730
731 auto joint3 = table.addClass<Joint3D>(
732 "Joint3D", std::function<Joint3D *()>([]() -> Joint3D * { return nullptr; }), true);
733 joint3.addFunc("getId", &Joint3D::getId);
734 joint3.addFunc("getKind", &Joint3D::getKind);
735 joint3.addFunc("getBodyAId", &Joint3D::getBodyAId);
736 joint3.addFunc("getBodyBId", &Joint3D::getBodyBId);
737 joint3.addFunc("setCollideConnected", &Joint3D::setCollideConnected);
738 joint3.addFunc("getCollideConnected", &Joint3D::getCollideConnected);
739 joint3.addFunc("setForceThreshold", &Joint3D::setForceThreshold);
740 joint3.addFunc("getForceThreshold", &Joint3D::getForceThreshold);
741 joint3.addFunc("setTorqueThreshold", &Joint3D::setTorqueThreshold);
742 joint3.addFunc("getTorqueThreshold", &Joint3D::getTorqueThreshold);
743 joint3.addFunc("getConstraintForceX", &Joint3D::getConstraintForceX);
744 joint3.addFunc("getConstraintForceY", &Joint3D::getConstraintForceY);
745 joint3.addFunc("getConstraintForceZ", &Joint3D::getConstraintForceZ);
746 joint3.addFunc("getConstraintTorqueX", &Joint3D::getConstraintTorqueX);
747 joint3.addFunc("getConstraintTorqueY", &Joint3D::getConstraintTorqueY);
748 joint3.addFunc("getConstraintTorqueZ", &Joint3D::getConstraintTorqueZ);
749 joint3.addFunc("getLinearSeparation", &Joint3D::getLinearSeparation);
750 joint3.addFunc("getAngularSeparation", &Joint3D::getAngularSeparation);
751 joint3.addFunc("setDistanceLength", &Joint3D::setDistanceLength);
752 joint3.addFunc("getDistanceLength", &Joint3D::getDistanceLength);
753 joint3.addFunc("getDistanceCurrentLength", &Joint3D::getDistanceCurrentLength);
754 joint3.addFunc("setDistanceSpring", &Joint3D::setDistanceSpring);
755 joint3.addFunc("setDistanceLimits", &Joint3D::setDistanceLimits);
756 joint3.addFunc("setDistanceMotor", &Joint3D::setDistanceMotor);
757 joint3.addFunc("setRevoluteSpring", &Joint3D::setRevoluteSpring);
758 joint3.addFunc("setRevoluteLimits", &Joint3D::setRevoluteLimits);
759 joint3.addFunc("setRevoluteMotor", &Joint3D::setRevoluteMotor);
760 joint3.addFunc("getRevoluteAngle", &Joint3D::getRevoluteAngle);
761 joint3.addFunc("getRevoluteMotorTorque", &Joint3D::getRevoluteMotorTorque);
762 joint3.addFunc("setPrismaticSpring", &Joint3D::setPrismaticSpring);
763 joint3.addFunc("setPrismaticLimits", &Joint3D::setPrismaticLimits);
764 joint3.addFunc("setPrismaticMotor", &Joint3D::setPrismaticMotor);
765 joint3.addFunc("getPrismaticTranslation", &Joint3D::getPrismaticTranslation);
766 joint3.addFunc("getPrismaticSpeed", &Joint3D::getPrismaticSpeed);
767 joint3.addFunc("getPrismaticMotorForce", &Joint3D::getPrismaticMotorForce);
768 joint3.addFunc("setSphericalConeLimit", &Joint3D::setSphericalConeLimit);
769 joint3.addFunc("setSphericalTwistLimits", &Joint3D::setSphericalTwistLimits);
770 joint3.addFunc("setSphericalMotor", &Joint3D::setSphericalMotor);
771 joint3.addFunc("getSphericalConeAngle", &Joint3D::getSphericalConeAngle);
772 joint3.addFunc("getSphericalTwistAngle", &Joint3D::getSphericalTwistAngle);
773 joint3.addFunc("setWheelSuspension", &Joint3D::setWheelSuspension);
774 joint3.addFunc("setWheelSuspensionLimits", &Joint3D::setWheelSuspensionLimits);
775 joint3.addFunc("setWheelSpinMotor", &Joint3D::setWheelSpinMotor);
776 joint3.addFunc("setWheelSteering", &Joint3D::setWheelSteering);
777 joint3.addFunc("setWheelSteeringLimits", &Joint3D::setWheelSteeringLimits);
778 joint3.addFunc("getWheelSpinSpeed", &Joint3D::getWheelSpinSpeed);
779 joint3.addFunc("getWheelSpinTorque", &Joint3D::getWheelSpinTorque);
780 joint3.addFunc("getWheelSteeringAngle", &Joint3D::getWheelSteeringAngle);
781 joint3.addFunc("getWheelSteeringTorque", &Joint3D::getWheelSteeringTorque);
782 joint3.addFunc("setWeldLinearSpring", &Joint3D::setWeldLinearSpring);
783 joint3.addFunc("setWeldAngularSpring", &Joint3D::setWeldAngularSpring);
784 joint3.addFunc("getWeldLinearHertz", &Joint3D::getWeldLinearHertz);
785 joint3.addFunc("getWeldLinearDampingRatio", &Joint3D::getWeldLinearDampingRatio);
786 joint3.addFunc("getWeldAngularHertz", &Joint3D::getWeldAngularHertz);
787 joint3.addFunc("getWeldAngularDampingRatio", &Joint3D::getWeldAngularDampingRatio);
788 joint3.addFunc("setMotorLinearVelocity", &Joint3D::setMotorLinearVelocity);
789 joint3.addFunc("setMotorAngularVelocity", &Joint3D::setMotorAngularVelocity);
790 joint3.addFunc("setMotorVelocityLimits", &Joint3D::setMotorVelocityLimits);
791 joint3.addFunc("setMotorLinearSpring", &Joint3D::setMotorLinearSpring);
792 joint3.addFunc("setMotorAngularSpring", &Joint3D::setMotorAngularSpring);
793 joint3.addFunc("getMotorLinearVelocityX", &Joint3D::getMotorLinearVelocityX);
794 joint3.addFunc("getMotorLinearVelocityY", &Joint3D::getMotorLinearVelocityY);
795 joint3.addFunc("getMotorLinearVelocityZ", &Joint3D::getMotorLinearVelocityZ);
796 joint3.addFunc("getMotorAngularVelocityX", &Joint3D::getMotorAngularVelocityX);
797 joint3.addFunc("getMotorAngularVelocityY", &Joint3D::getMotorAngularVelocityY);
798 joint3.addFunc("getMotorAngularVelocityZ", &Joint3D::getMotorAngularVelocityZ);
799 joint3.addFunc("setParallelSpring", &Joint3D::setParallelSpring);
800 joint3.addFunc("getParallelHertz", &Joint3D::getParallelHertz);
801 joint3.addFunc("getParallelDampingRatio", &Joint3D::getParallelDampingRatio);
802 joint3.addFunc("getParallelMaxTorque", &Joint3D::getParallelMaxTorque);
803 joint3.addFunc("destroy", &Joint3D::destroy);
804
805 auto mechanism3 = table.addClass<Mechanism3D>(
806 "Mechanism3D", std::function<Mechanism3D *()>([]() -> Mechanism3D * { return nullptr; }),
807 true);
808 mechanism3.addFunc("getId", &Mechanism3D::getId);
809 mechanism3.addFunc("getKind", &Mechanism3D::getKind);
810 mechanism3.addFunc("isValid", &Mechanism3D::isValid);
811 mechanism3.addFunc("getDriveJoint", &Mechanism3D::getDriveJoint);
812 mechanism3.addFunc("getCrankPinJoint", &Mechanism3D::getCrankPinJoint);
813 mechanism3.addFunc("getSliderPinJoint", &Mechanism3D::getSliderPinJoint);
814 mechanism3.addFunc("getSliderJoint", &Mechanism3D::getSliderJoint);
815 mechanism3.addFunc("getDriveAngle", &Mechanism3D::getDriveAngle);
816 mechanism3.addFunc("getSliderTranslation", &Mechanism3D::getSliderTranslation);
817 mechanism3.addFunc("getSpinSpeed", &Mechanism3D::getSpinSpeed);
818 mechanism3.addFunc("setDrive", &Mechanism3D::setDrive);
819 mechanism3.addFunc("clearDrive", &Mechanism3D::clearDrive);
820 mechanism3.addFunc("isDriveEnabled", &Mechanism3D::isDriveEnabled);
821 mechanism3.addFunc("setRatchetDirection", &Mechanism3D::setRatchetDirection);
822 mechanism3.addFunc("getRatchetDirection", &Mechanism3D::getRatchetDirection);
823 mechanism3.addFunc("setRatchetEngagementTorque", &Mechanism3D::setRatchetEngagementTorque);
824 mechanism3.addFunc("getRatchetEngagementTorque", &Mechanism3D::getRatchetEngagementTorque);
825 mechanism3.addFunc("destroy", &Mechanism3D::destroy);
826
827 auto fixture = table.addClass<Fixture>(
828 "Fixture", std::function<Fixture *()>([]() -> Fixture * { return nullptr; }), true);
829 fixture.addFunc("setSensor", &Fixture::setSensor);
830 fixture.addFunc("isSensor", &Fixture::isSensor);
831 fixture.addFunc("setFriction", &Fixture::setFriction);
832 fixture.addFunc("getFriction", &Fixture::getFriction);
833 fixture.addFunc("setRestitution", &Fixture::setRestitution);
834 fixture.addFunc("getRestitution", &Fixture::getRestitution);
835 fixture.addFunc("setDensity", &Fixture::setDensity);
836 fixture.addFunc("getDensity", &Fixture::getDensity);
837 fixture.addFunc("setTag", &Fixture::setTag);
838 fixture.addFunc("getTag", &Fixture::getTag);
839 fixture.addFunc("setCategoryBits", &Fixture::setCategoryBits);
840 fixture.addFunc("getCategoryBits", &Fixture::getCategoryBits);
841 fixture.addFunc("setMaskBits", &Fixture::setMaskBits);
842 fixture.addFunc("getMaskBits", &Fixture::getMaskBits);
843 fixture.addFunc("setGroupIndex", &Fixture::setGroupIndex);
844 fixture.addFunc("getGroupIndex", &Fixture::getGroupIndex);
845 fixture.addFunc("getBodyId", &Fixture::getBodyId);
846 fixture.addFunc("getBody", &Fixture::getBody);
847 fixture.addFunc("testPoint", &Fixture::testPoint);
848 fixture.addFunc("destroy", &Fixture::destroy);
849
850 auto shape3 = table.addClass<Shape3D>(
851 "Shape3D", std::function<Shape3D *()>([]() -> Shape3D * { return nullptr; }), true);
852 shape3.addFunc("getId", &Shape3D::getId);
853 shape3.addFunc("setTag", &Shape3D::setTag);
854 shape3.addFunc("getTag", &Shape3D::getTag);
855 shape3.addFunc("setHitEventsEnabled", &Shape3D::setHitEventsEnabled);
856 shape3.addFunc("areHitEventsEnabled", &Shape3D::areHitEventsEnabled);
857 shape3.addFunc("setOneWay", &Shape3D::setOneWay);
858 shape3.addFunc("disableOneWay", &Shape3D::disableOneWay);
859 shape3.addFunc("isOneWay", &Shape3D::isOneWay);
860 shape3.addFunc("getKind", &Shape3D::getKind);
861 shape3.addFunc("setBoxSize", &Shape3D::setBoxSize);
862 shape3.addFunc("setSphereRadius", &Shape3D::setSphereRadius);
863 shape3.addFunc("setCapsuleSize", &Shape3D::setCapsuleSize);
864 shape3.addFunc("setConvexHullVertices",
865 [](Shape3D *shape, ssq::Array values, int maxVertices) {
866 std::vector<float> vertices;
867 vertices.reserve(values.size());
868 for (size_t i = 0; i < values.size(); ++i)
869 vertices.push_back(values.get<float>(i));
870 shape->setConvexHullVertices(vertices, maxVertices);
871 });
872 shape3.addFunc("getConvexHullPointCount", &Shape3D::getConvexHullPointCount);
873 shape3.addFunc("getConvexHullMaxVertices", &Shape3D::getConvexHullMaxVertices);
874 shape3.addFunc("setTriangleMeshData",
875 [](Shape3D *shape, ssq::Array vertexValues, ssq::Array indexValues) {
876 std::vector<float> vertices;
877 std::vector<int32_t> indices;
878 vertices.reserve(vertexValues.size());
879 indices.reserve(indexValues.size());
880 for (size_t i = 0; i < vertexValues.size(); ++i)
881 vertices.push_back(vertexValues.get<float>(i));
882 for (size_t i = 0; i < indexValues.size(); ++i)
883 indices.push_back(indexValues.get<int32_t>(i));
884 shape->setTriangleMeshData(vertices, indices);
885 });
886 shape3.addFunc(
887 "setTriangleMeshDataFull",
888 [](Shape3D *shape, ssq::Array vertexValues, ssq::Array indexValues, bool weldVertices,
889 float weldTolerance, bool identifyEdges, bool useMedianSplit) {
890 std::vector<float> vertices;
891 std::vector<int32_t> indices;
892 vertices.reserve(vertexValues.size());
893 indices.reserve(indexValues.size());
894 for (size_t i = 0; i < vertexValues.size(); ++i)
895 vertices.push_back(vertexValues.get<float>(i));
896 for (size_t i = 0; i < indexValues.size(); ++i)
897 indices.push_back(indexValues.get<int32_t>(i));
898 shape->setTriangleMeshData(vertices, indices, weldVertices, weldTolerance,
899 identifyEdges, useMedianSplit);
900 });
901 shape3.addFunc("getTriangleMeshVertexCount", &Shape3D::getTriangleMeshVertexCount);
902 shape3.addFunc("getTriangleMeshTriangleCount", &Shape3D::getTriangleMeshTriangleCount);
903 shape3.addFunc("setTriangleMeshMaterialIndices", [](Shape3D *shape, ssq::Array values) {
904 std::vector<int32_t> indices;
905 indices.reserve(values.size());
906 for (size_t i = 0; i < values.size(); ++i)
907 indices.push_back(values.get<int32_t>(i));
908 shape->setTriangleMeshMaterialIndices(indices);
909 });
910 shape3.addFunc("getTriangleMeshMaterialIndex",
912 shape3.addFunc("getTriangleMeshMaterialCount",
914 shape3.addFunc("setTriangleMeshMaterial", &Shape3D::setTriangleMeshMaterial);
915 shape3.addFunc("getTriangleMeshMaterialFriction",
917 shape3.addFunc("getTriangleMeshMaterialRestitution",
919 shape3.addFunc("getTriangleMeshMaterialRollingResistance",
921 shape3.addFunc("getTriangleMeshMaterialId", &Shape3D::getTriangleMeshMaterialId);
922 shape3.addFunc("setHeightFieldHeights", [](Shape3D *shape, ssq::Array values) {
923 std::vector<float> heights;
924 heights.reserve(values.size());
925 for (size_t i = 0; i < values.size(); ++i)
926 heights.push_back(values.get<float>(i));
927 shape->setHeightFieldHeights(heights);
928 });
929 shape3.addFunc("setHeightFieldRegion",
930 [](Shape3D *shape, int x, int z, int width, int depth,
931 ssq::Array values) {
932 std::vector<float> heights;
933 heights.reserve(values.size());
934 for (size_t i = 0; i < values.size(); ++i)
935 heights.push_back(values.get<float>(i));
936 shape->setHeightFieldRegion(x, z, width, depth, heights);
937 });
938 shape3.addFunc("getHeightFieldHeight", &Shape3D::getHeightFieldHeight);
939 shape3.addFunc("getHeightFieldCountX", &Shape3D::getHeightFieldCountX);
940 shape3.addFunc("getHeightFieldCountZ", &Shape3D::getHeightFieldCountZ);
941 shape3.addFunc("getHeightFieldCellSizeX", &Shape3D::getHeightFieldCellSizeX);
942 shape3.addFunc("getHeightFieldCellSizeZ", &Shape3D::getHeightFieldCellSizeZ);
943 shape3.addFunc("getHeightFieldGlobalMin", &Shape3D::getHeightFieldGlobalMin);
944 shape3.addFunc("getHeightFieldGlobalMax", &Shape3D::getHeightFieldGlobalMax);
945 shape3.addFunc("getBoxWidth", &Shape3D::getBoxWidth);
946 shape3.addFunc("getBoxHeight", &Shape3D::getBoxHeight);
947 shape3.addFunc("getBoxDepth", &Shape3D::getBoxDepth);
948 shape3.addFunc("getRadius", &Shape3D::getRadius);
949 shape3.addFunc("getCapsuleHeight", &Shape3D::getCapsuleHeight);
950 shape3.addFunc("setLocalTransform", &Shape3D::setLocalTransform);
951 shape3.addFunc("setLocalPosition", &Shape3D::setLocalPosition);
952 shape3.addFunc("setLocalRotation", &Shape3D::setLocalRotation);
953 shape3.addFunc("getLocalX", &Shape3D::getLocalX);
954 shape3.addFunc("getLocalY", &Shape3D::getLocalY);
955 shape3.addFunc("getLocalZ", &Shape3D::getLocalZ);
956 shape3.addFunc("getLocalRotX", &Shape3D::getLocalRotX);
957 shape3.addFunc("getLocalRotY", &Shape3D::getLocalRotY);
958 shape3.addFunc("getLocalRotZ", &Shape3D::getLocalRotZ);
959 shape3.addFunc("getLocalRotW", &Shape3D::getLocalRotW);
960 shape3.addFunc("setSensor", &Shape3D::setSensor);
961 shape3.addFunc("isSensor", &Shape3D::isSensor);
962 shape3.addFunc("setFriction", &Shape3D::setFriction);
963 shape3.addFunc("getFriction", &Shape3D::getFriction);
964 shape3.addFunc("setRestitution", &Shape3D::setRestitution);
965 shape3.addFunc("getRestitution", &Shape3D::getRestitution);
966 shape3.addFunc("setRollingResistance", &Shape3D::setRollingResistance);
967 shape3.addFunc("getRollingResistance", &Shape3D::getRollingResistance);
968 shape3.addFunc("setTangentVelocity", &Shape3D::setTangentVelocity);
969 shape3.addFunc("getTangentVelocityX", &Shape3D::getTangentVelocityX);
970 shape3.addFunc("getTangentVelocityY", &Shape3D::getTangentVelocityY);
971 shape3.addFunc("getTangentVelocityZ", &Shape3D::getTangentVelocityZ);
972 shape3.addFunc("setMaterialId", &Shape3D::setMaterialId);
973 shape3.addFunc("getMaterialId", &Shape3D::getMaterialId);
974 shape3.addFunc("setExplosionScale", &Shape3D::setExplosionScale);
975 shape3.addFunc("getExplosionScale", &Shape3D::getExplosionScale);
976 shape3.addFunc("setFrictionCombineMode", &Shape3D::setFrictionCombineMode);
977 shape3.addFunc("getFrictionCombineMode", &Shape3D::getFrictionCombineMode);
978 shape3.addFunc("setRestitutionCombineMode", &Shape3D::setRestitutionCombineMode);
979 shape3.addFunc("getRestitutionCombineMode", &Shape3D::getRestitutionCombineMode);
980 shape3.addFunc("setDensity", &Shape3D::setDensity);
981 shape3.addFunc("getDensity", &Shape3D::getDensity);
982 shape3.addFunc("setCategoryBits", [](Shape3D *shape, int64_t bits) {
983 shape->setCategoryBits(static_cast<uint64_t>(bits));
984 });
985 shape3.addFunc("getCategoryBits", [](Shape3D *shape) {
986 return static_cast<int64_t>(shape->getCategoryBits());
987 });
988 shape3.addFunc("setMaskBits", [](Shape3D *shape, int64_t bits) {
989 shape->setMaskBits(static_cast<uint64_t>(bits));
990 });
991 shape3.addFunc("getMaskBits", [](Shape3D *shape) {
992 return static_cast<int64_t>(shape->getMaskBits());
993 });
994 shape3.addFunc("setGroupIndex", &Shape3D::setGroupIndex);
995 shape3.addFunc("getGroupIndex", &Shape3D::getGroupIndex);
996 shape3.addFunc("getBody", [](Shape3D *shape) { return shape->getBody(); });
997 shape3.addFunc("testPoint", &Shape3D::testPoint);
998 shape3.addFunc("destroy", &Shape3D::destroy);
999
1000 auto soft3 = table.addClass<SoftBody3D>(
1001 "SoftBody3D", std::function<SoftBody3D *()>([]() -> SoftBody3D * { return nullptr; }), true);
1002 soft3.addFunc("update", &SoftBody3D::update);
1003 soft3.addFunc("setGravity", &SoftBody3D::setGravity);
1004 soft3.addFunc("getGravityX", &SoftBody3D::getGravityX);
1005 soft3.addFunc("getGravityY", &SoftBody3D::getGravityY);
1006 soft3.addFunc("getGravityZ", &SoftBody3D::getGravityZ);
1007 soft3.addFunc("setDeformationResistance", &SoftBody3D::setDeformationResistance);
1008 soft3.addFunc("getDeformationResistance", &SoftBody3D::getDeformationResistance);
1009 soft3.addFunc("setIterations", &SoftBody3D::setIterations);
1010 soft3.addFunc("getIterations", &SoftBody3D::getIterations);
1011 soft3.addFunc("setDamping", &SoftBody3D::setDamping);
1012 soft3.addFunc("getDamping", &SoftBody3D::getDamping);
1013 soft3.addFunc("setParticleRadius", &SoftBody3D::setParticleRadius);
1014 soft3.addFunc("getParticleRadius", &SoftBody3D::getParticleRadius);
1015 soft3.addFunc("setParticleMass", &SoftBody3D::setParticleMass);
1016 soft3.addFunc("getParticleMass", &SoftBody3D::getParticleMass);
1017 soft3.addFunc("setPlasticity", &SoftBody3D::setPlasticity);
1018 soft3.addFunc("getPlasticYield", &SoftBody3D::getPlasticYield);
1019 soft3.addFunc("getPlasticCreep", &SoftBody3D::getPlasticCreep);
1020 soft3.addFunc("getPlasticRecovery", &SoftBody3D::getPlasticRecovery);
1021 soft3.addFunc("getMaxDeformation", &SoftBody3D::getMaxDeformation);
1022 soft3.addFunc("setSelfCollision", &SoftBody3D::setSelfCollision);
1023 soft3.addFunc("getSelfCollision", &SoftBody3D::getSelfCollision);
1024 soft3.addFunc("setBounds", &SoftBody3D::setBounds);
1025 soft3.addFunc("clearBounds", &SoftBody3D::clearBounds);
1026 soft3.addFunc("pin", &SoftBody3D::pin);
1027 soft3.addFunc("unpin", &SoftBody3D::unpin);
1028 soft3.addFunc("isPinned", &SoftBody3D::isPinned);
1029 soft3.addFunc("grabAt", &SoftBody3D::grabAt);
1030 soft3.addFunc("moveGrab", &SoftBody3D::moveGrab);
1031 soft3.addFunc("releaseGrab", &SoftBody3D::releaseGrab);
1032 soft3.addFunc("isGrabbing", &SoftBody3D::isGrabbing);
1033 soft3.addFunc("getGrabIndex", &SoftBody3D::getGrabIndex);
1034 soft3.addFunc("applyForce", &SoftBody3D::applyForce);
1035 soft3.addFunc("interactAt", &SoftBody3D::interactAt);
1036 soft3.addFunc("setCollideWorld", &SoftBody3D::setCollideWorld);
1037 soft3.addFunc("getCollideWorld", &SoftBody3D::getCollideWorld);
1038 soft3.addFunc("reset", &SoftBody3D::reset);
1039 soft3.addFunc("getCols", &SoftBody3D::getCols);
1040 soft3.addFunc("getRows", &SoftBody3D::getRows);
1041 soft3.addFunc("getLayers", &SoftBody3D::getLayers);
1042 soft3.addFunc("getParticleCount", &SoftBody3D::getParticleCount);
1043 soft3.addFunc("getParticleX", &SoftBody3D::getParticleX);
1044 soft3.addFunc("getParticleY", &SoftBody3D::getParticleY);
1045 soft3.addFunc("getParticleZ", &SoftBody3D::getParticleZ);
1046 soft3.addFunc("setParticlePosition", &SoftBody3D::setParticlePosition);
1047 soft3.addFunc("getVolumeRatio", &SoftBody3D::getVolumeRatio);
1048 soft3.addFunc("destroy", &SoftBody3D::destroy);
1049
1050 auto soft3Renderer = table.addClass<SoftBody3DRenderer>(
1051 "SoftBody3DRenderer",
1052 std::function<SoftBody3DRenderer *()>([]() -> SoftBody3DRenderer * { return nullptr; }), true);
1053 soft3Renderer.addFunc("setBody", &SoftBody3DRenderer::setBody);
1054 soft3Renderer.addFunc("setColor", &SoftBody3DRenderer::setColor);
1055 soft3Renderer.addFunc("draw", &SoftBody3DRenderer::draw);
1056
1057 auto fluid = table.addClass<Fluid2D>(
1058 "Fluid2D", std::function<Fluid2D *()>([]() -> Fluid2D * { return nullptr; }), true);
1059 fluid.addFunc("update", &Fluid2D::update);
1060 fluid.addFunc("setGravity", &Fluid2D::setGravity);
1061 fluid.addFunc("getGravityX", &Fluid2D::getGravityX);
1062 fluid.addFunc("getGravityY", &Fluid2D::getGravityY);
1063 fluid.addFunc("setSmoothingRadius", &Fluid2D::setSmoothingRadius);
1064 fluid.addFunc("getSmoothingRadius", &Fluid2D::getSmoothingRadius);
1065 fluid.addFunc("setRestDensity", &Fluid2D::setRestDensity);
1066 fluid.addFunc("getRestDensity", &Fluid2D::getRestDensity);
1067 fluid.addFunc("setPressureStiffness", &Fluid2D::setPressureStiffness);
1068 fluid.addFunc("getPressureStiffness", &Fluid2D::getPressureStiffness);
1069 fluid.addFunc("setNearPressureStiffness", &Fluid2D::setNearPressureStiffness);
1070 fluid.addFunc("getNearPressureStiffness", &Fluid2D::getNearPressureStiffness);
1071 fluid.addFunc("setViscosity", &Fluid2D::setViscosity);
1072 fluid.addFunc("getViscosity", &Fluid2D::getViscosity);
1073 fluid.addFunc("setIterations", &Fluid2D::setIterations);
1074 fluid.addFunc("getIterations", &Fluid2D::getIterations);
1075 fluid.addFunc("setBounds", &Fluid2D::setBounds);
1076 fluid.addFunc("clearBounds", &Fluid2D::clearBounds);
1077 fluid.addFunc("emit", &Fluid2D::emit);
1078 fluid.addFunc("clear", &Fluid2D::clear);
1079 fluid.addFunc("interactAt", &Fluid2D::interactAt);
1080 fluid.addFunc("setColor", &Fluid2D::setColor);
1081 fluid.addFunc("setParticleSize", &Fluid2D::setParticleSize);
1082 fluid.addFunc("getParticleSize", &Fluid2D::getParticleSize);
1083 fluid.addFunc("draw", &Fluid2D::draw);
1084 fluid.addFunc("getCapacity", &Fluid2D::getCapacity);
1085 fluid.addFunc("getParticleCount", &Fluid2D::getParticleCount);
1086 fluid.addFunc("getParticleX", &Fluid2D::getParticleX);
1087 fluid.addFunc("getParticleY", &Fluid2D::getParticleY);
1088 fluid.addFunc("getParticleVx", &Fluid2D::getParticleVx);
1089 fluid.addFunc("getParticleVy", &Fluid2D::getParticleVy);
1090 fluid.addFunc("destroy", &Fluid2D::destroy);
1091}
1092
1093void Physics::expose(ssq::Class &cls) {
1094 cls.addFunc("getName", &Physics::getName);
1095 cls.addFunc("setMeter", &Physics::setMeter);
1096 cls.addFunc("getMeter", &Physics::getMeter);
1097 cls.addFunc("newWorld", &Physics::newWorld);
1098 cls.addFunc("newWorld3D", &Physics::newWorld3D);
1099 cls.addFunc("newDistanceField3D", &Physics::newDistanceField3D);
1100 cls.addFunc("newSoftBody3D", &Physics::newSoftBody3D);
1101 cls.addFunc("newSoftBody3DRenderer", &Physics::newSoftBody3DRenderer);
1102 cls.addFunc("newFluid2D", &Physics::newFluid2D);
1103}
1104
1105} // namespace eve::physics
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
float z
Definition AnimClip.cpp:738
HSQUIRRELVM vm
Definition ECS.cpp:20
HSQOBJECT cls
Definition ECS.cpp:21
std::map< std::string, Var > values
int rows
int cols
std::uint32_t capacity
ShaderImageInput shape
std::vector< std::uint32_t > indices
std::uint32_t height
std::uint32_t width
Range range
std::string name
#define Module_IMPL(ModuleName, newExpr)
Definition Module.h:26
World3D * world
std::vector< Point > vertices
int created
std::uint32_t count
The single Squirrel projection for common Result, Status and Value.
int spacing
std::string body
std::uint32_t depth
EVENGINE_API_FOUNDATION public API.
Definition Exception.h:13
virtual std::string getName() const =0
Returns the name.
The canonical owning dynamic value used by data-facing protocols.
Definition Value.h:31
3D rigid body (Box3D) in meter-space coordinates (+Y up by convention). Owned by a World3D; create pr...
Definition Body3D.h:24
bool isAngularYLocked() const
Whether rotation around Y is locked.
void setActive(bool active)
Disables/enables the body and its shapes.
Definition Body3D.cpp:691
bool isAngularXLocked() const
Whether rotation around X is locked.
void setRotation(float qx, float qy, float qz, float qw)
Orientation as quaternion (x, y, z, w).
Definition Body3D.cpp:274
std::vector< float > localToWorldVector(float x, float y, float z) const
Rotates a body-local direction/vector into world space; returns {x,y,z}.
Definition Body3D.cpp:386
float getInertiaYZ() const
Local symmetric inertia tensor YZ component.
std::vector< float > worldToLocalVector(float x, float y, float z) const
Rotates a world direction/vector into body-local space; returns {x,y,z}.
Definition Body3D.cpp:400
float getLocalCenterY() const
Local center of mass Y coordinate.
bool isBullet() const
True when bullet.
Definition Body3D.cpp:706
void setAngularDamping(float damping)
Angular damping coefficient, finite and non-negative.
Definition Body3D.cpp:529
bool isAngularZLocked() const
Whether rotation around Z is locked.
bool isActive() const
True when active.
Definition Body3D.cpp:699
void applyForce(float fx, float fy, float fz)
Force applied at the center of mass.
Definition Body3D.cpp:428
float getWorldCenterX() const
World center of mass X coordinate.
float getLinearVelocityY() const
Returns the linear velocity y.
Definition Body3D.cpp:321
std::vector< float > localToWorldPoint(float x, float y, float z) const
Converts a body-local point to world coordinates; returns {x,y,z}.
Definition Body3D.cpp:356
void applyLinearImpulse(float ix, float iy, float iz)
Instantaneous linear impulse.
Definition Body3D.cpp:443
void setFixedRotation(bool fixed)
Lock all angular axes (Box3D motion locks).
Definition Body3D.cpp:676
void applyAngularImpulse(float ix, float iy, float iz)
Instantaneous angular impulse.
Definition Body3D.cpp:453
float getInertiaYY() const
Local inertia tensor YY component about the center of mass.
float getAngularDamping() const
Current angular damping coefficient.
Definition Body3D.cpp:535
float getX() const
Returns the x.
Definition Body3D.cpp:259
void setLinearDamping(float damping)
Linear damping coefficient, finite and non-negative.
Definition Body3D.cpp:519
std::vector< float > worldToLocalPoint(float x, float y, float z) const
Converts a world point to body-local coordinates; returns {x,y,z}.
Definition Body3D.cpp:372
void applyLocalForceToCenter(float fx, float fy, float fz)
Body-local force applied at the center of mass.
Definition Body3D.cpp:467
bool isLinearYLocked() const
Whether translation along Y is locked.
float getMass() const
Body mass in kg.
Definition Body3D.cpp:331
bool isFixedRotation() const
True when fixed rotation.
Definition Body3D.cpp:685
void setBullet(bool bullet)
CCD bullet mode.
Definition Body3D.cpp:701
Shape3D * newBoxShape(float width, float height, float depth, float density=1.f, float friction=0.2f, float restitution=0.f)
Creates a box shape in meter-space units.
Definition Body3D.cpp:715
void applyLocalTorque(float tx, float ty, float tz)
Body-local torque.
Definition Body3D.cpp:474
float getY() const
Returns the y.
Definition Body3D.cpp:264
void setAwake(bool awake)
Wakes / sleeps the body manually.
Definition Body3D.cpp:708
void applyLinearImpulseAt(float ix, float iy, float iz, float x, float y, float z)
Instantaneous linear impulse applied at a world position.
Definition Body3D.cpp:448
float getLinearDamping() const
Current linear damping coefficient.
Definition Body3D.cpp:525
float getInertiaXZ() const
Local symmetric inertia tensor XZ component.
void destroy()
Destroys the body inside its world.
Definition Body3D.cpp:225
float getRotZ() const
Returns the rot z.
Definition Body3D.cpp:301
float getSleepThreshold() const
Current sleep velocity threshold.
Definition Body3D.cpp:564
void setMassProperties(float mass, float centerX, float centerY, float centerZ, float inertiaXX, float inertiaYY, float inertiaZZ, float inertiaXY=0.f, float inertiaXZ=0.f, float inertiaYZ=0.f)
Overrides mass, local center of mass, and the symmetric local inertia tensor.
Definition Body3D.cpp:588
void setTargetTransform(float x, float y, float z, float qx, float qy, float qz, float qw, float timeStep)
Drives a kinematic body to a target pose over a positive time step. The target quaternion is normaliz...
Definition Body3D.cpp:504
float getRotY() const
Returns the rot y.
Definition Body3D.cpp:296
void applyLocalForce(float fx, float fy, float fz, float x, float y, float z)
Body-local force applied at a body-local point.
Definition Body3D.cpp:458
bool isLinearZLocked() const
Whether translation along Z is locked.
float getGravityScale() const
Current world-gravity multiplier.
Definition Body3D.cpp:545
float getLocalCenterZ() const
Local center of mass Z coordinate.
float getRotX() const
Returns the rot x.
Definition Body3D.cpp:291
bool isLinearXLocked() const
Whether translation along X is locked.
float getAngularVelocityZ() const
Returns the angular velocity z.
Definition Body3D.cpp:351
void setSleepEnabled(bool enabled)
Enables or disables automatic sleeping for this body.
Definition Body3D.cpp:549
int getId() const
Stable id used by collision events.
Definition Body3D.h:35
void applyLocalLinearImpulseToCenter(float ix, float iy, float iz)
Body-local linear impulse applied at the center of mass.
Definition Body3D.cpp:490
float getAngularVelocityX() const
Returns the angular velocity x.
Definition Body3D.cpp:341
std::string getType() const
Returns the type.
Definition Body3D.cpp:671
float getRotW() const
Returns the rot w.
Definition Body3D.cpp:306
void applyTorque(float tx, float ty, float tz)
Torque applied in world space.
Definition Body3D.cpp:438
bool isSleepEnabled() const
Whether automatic sleeping is enabled.
Definition Body3D.cpp:554
float getInertiaXX() const
Local inertia tensor XX component about the center of mass.
void setMotionLocks(bool linearX, bool linearY, bool linearZ, bool angularX, bool angularY, bool angularZ)
Atomically locks translation and rotation on individual local solver axes.
Definition Body3D.cpp:568
void applyForceAt(float fx, float fy, float fz, float x, float y, float z)
Force applied at a world position.
Definition Body3D.cpp:433
void resetMassProperties()
Restores automatic mass, center, and inertia calculation from attached shapes.
Definition Body3D.cpp:627
float getInertiaXY() const
Local symmetric inertia tensor XY component.
float getWorldCenterZ() const
World center of mass Z coordinate.
float getInertiaZZ() const
Local inertia tensor ZZ component about the center of mass.
Shape3D * newCapsuleShape(float height, float radius, float density=1.f, float friction=0.2f, float restitution=0.f)
Creates a capsule along local Y.
Definition Body3D.cpp:753
void setLinearVelocity(float vx, float vy, float vz)
Linear velocity in m/s.
Definition Body3D.cpp:311
void applyLocalLinearImpulse(float ix, float iy, float iz, float x, float y, float z)
Body-local linear impulse applied at a body-local point.
Definition Body3D.cpp:480
float getWorldCenterY() const
World center of mass Y coordinate.
void setGravityScale(float scale)
Multiplier applied to world gravity; may be negative.
Definition Body3D.cpp:539
bool isAwake() const
True when awake.
Definition Body3D.cpp:713
void setPosition(float x, float y, float z)
Position in meters.
Definition Body3D.cpp:254
void setType(const std::string &bodyType)
"static" | "kinematic" | "dynamic".
Definition Body3D.cpp:656
float getLocalCenterX() const
Local center of mass X coordinate.
float getLinearVelocityZ() const
Returns the linear velocity z.
Definition Body3D.cpp:326
std::vector< float > getWorldPointVelocity(float x, float y, float z) const
World-space velocity at the supplied world point.
Definition Body3D.cpp:421
void setAngularVelocity(float wx, float wy, float wz)
Angular velocity in rad/s.
Definition Body3D.cpp:336
void setSleepThreshold(float threshold)
Sleep velocity threshold, finite and non-negative.
Definition Body3D.cpp:558
float getAngularVelocityY() const
Returns the angular velocity y.
Definition Body3D.cpp:346
std::vector< float > getLocalPointVelocity(float x, float y, float z) const
World-space velocity at a point expressed in body-local coordinates.
Definition Body3D.cpp:407
float getZ() const
Returns the z.
Definition Body3D.cpp:269
Shape3D * newSphereShape(float radius, float density=1.f, float friction=0.2f, float restitution=0.f)
Creates a sphere shape in meter-space units.
Definition Body3D.cpp:735
float getLinearVelocityX() const
Returns the linear velocity x.
Definition Body3D.cpp:316
void applyLocalAngularImpulse(float ix, float iy, float iz)
Body-local angular impulse.
Definition Body3D.cpp:497
Fixture * newRectangleFixture(float width, float height, float density=1.f, float friction=0.2f, float restitution=0.f)
Creates a rectangle fixture in pixel-space units.
Definition Body.cpp:228
float getLinearVelocityX() const
Returns the linear velocity x.
Definition Body.cpp:130
void applyForceAt(float fx, float fy, float x, float y)
Force applied at a world pixel position.
Definition Body.cpp:173
void setBullet(bool bullet)
CCD bullet mode (recommended for fast small bodies).
Definition Body.cpp:214
float getX() const
Returns the x.
Definition Body.cpp:105
void setAwake(bool awake)
Wakes / sleeps the body manually.
Definition Body.cpp:221
void setType(const std::string &bodyType)
"static" | "kinematic" | "dynamic".
Definition Body.cpp:190
void setAngle(float radians)
Rotation in radians.
Definition Body.cpp:115
float getLinearVelocityY() const
Returns the linear velocity y.
Definition Body.cpp:135
bool isActive() const
True when active.
Definition Body.cpp:212
void applyLinearImpulse(float ix, float iy)
Instantaneous linear impulse.
Definition Body.cpp:179
Fixture * newCircleFixture(float radius, float density=1.f, float friction=0.2f, float restitution=0.f)
Creates a circular fixture in pixel-space units.
Definition Body.cpp:256
void setFixedRotation(bool fixed)
Locks rotation so the body cannot spin.
Definition Body.cpp:200
void applyForce(float fx, float fy)
Force (pixels/s² * kg) applied at the center of mass.
Definition Body.cpp:167
bool isAwake() const
True when awake.
Definition Body.cpp:226
bool isFixedRotation() const
True when fixed rotation.
Definition Body.cpp:205
bool isBullet() const
True when bullet.
Definition Body.cpp:219
void setAngularVelocity(float omega)
Angular velocity in radians/s.
Definition Body.cpp:157
float getAngularVelocity() const
Returns the angular velocity.
Definition Body.cpp:162
void destroy()
Destroys the body inside its world.
Definition Body.cpp:72
void applyAngularImpulse(float impulse)
Instantaneous angular impulse.
Definition Body.cpp:185
float getWorldCenterY() const
Returns the world center y.
Definition Body.cpp:152
float getLinearSpeed() const
Magnitude of the linear velocity.
Definition Body.cpp:140
float getAngle() const
Returns the angle.
Definition Body.cpp:120
std::string getType() const
Returns the type.
Definition Body.cpp:195
int getId() const
Stable id used by contact/impact events.
Definition Body.h:32
void setPosition(float x, float y)
Position in pixels.
Definition Body.cpp:100
float getWorldCenterX() const
World center of mass in pixels.
Definition Body.cpp:147
Fixture * newRectangleFixtureAt(float width, float height, float offsetX, float offsetY, float density=1.f, float friction=0.2f, float restitution=0.f)
Creates an offset rectangle fixture in pixel-space units.
Definition Body.cpp:233
float getMass() const
Mass in kilograms (Box2D units).
Definition Body.cpp:145
void setActive(bool active)
Disables/enables the body and its fixtures.
Definition Body.cpp:207
void setLinearVelocity(float vx, float vy)
Linear velocity in pixels/s.
Definition Body.cpp:125
float getY() const
Returns the y.
Definition Body.cpp:110
Regular 3D signed-distance grid for terrain and voxel collision queries. Negative samples are solid,...
float getMoverGroundDot() const
Greatest dot product between mover Up and a normal from the latest move.
void setMoverGroundSnap(float distance)
Set the non-negative distance used to snap onto walkable ground after movement.
float getCollisionDistance() const
Signed clearance from the last check (negative means penetration).
float getCastDistance() const
World-space travel distance at the last cast hit.
void fill(float distance)
Set every grid sample to the same finite distance.
int getSampleCount() const
Total number of signed-distance samples.
bool moveCapsule(float ax, float ay, float az, float bx, float by, float bz, float radius, float deltaX, float deltaY, float deltaZ)
Resolve a capsule displacement against the field with sliding and depenetration. The capsule coordina...
float getCollisionY() const
Y coordinate of the closest sampled point from the last collision check.
void setMoverUp(float x, float y, float z)
Set the normalized reference-up direction used for ground classification.
void fillRegion(int x, int y, int z, int width, int height, int depth, float distance)
Fill an in-bounds grid subregion with one finite signed distance.
bool isMoverGrounded() const
Whether the latest move encountered a normal within the walkable slope limit.
float getMoverGroundSnap() const
Current post-move ground-snap distance.
void sampleNormal(float x, float y, float z)
Estimate the normalized outward field gradient at a world position.
float getOriginX() const
World-space X coordinate of grid vertex (0,0,0).
float getMoverStepHeight() const
Current automatic step height; zero disables step climbing.
bool checkCapsule(float ax, float ay, float az, float bx, float by, float bz, float radius)
Test a capsule defined by two sphere centers against the solid.
float getOriginY() const
World-space Y coordinate of grid vertex (0,0,0).
float getCellSize() const
World-space distance between adjacent grid vertices.
int getHeight() const
Number of grid vertices along the Y axis.
float getOutsideDistance() const
Distance returned for world samples outside the grid.
float getNormalZ() const
Z component of the most recently sampled collision normal.
float getMoverDeltaX() const
Resolved X displacement from the most recent moveCapsule call.
unsigned int getRevision() const
Monotonic wrapping counter incremented once after each successful mutation.
float getShapeContactY() const
Y coordinate on the sphere or capsule surface along the contact normal.
void setMoverSlopeLimit(float degrees)
Set the maximum walkable slope angle in degrees, clamped to [0, 89.9].
bool castCapsule(float ax, float ay, float az, float bx, float by, float bz, float radius, float deltaX, float deltaY, float deltaZ)
Sweep a capsule through the field and cache the earliest contact.
float getNormalX() const
X component of the most recently sampled collision normal.
bool castSphere(float x, float y, float z, float radius, float deltaX, float deltaY, float deltaZ)
Sweep a sphere through the field and cache the earliest contact.
float getMoverNormalX() const
X component of the most recent blocking or recovery normal.
float getMoverDeltaZ() const
Resolved Z displacement from the most recent moveCapsule call.
bool didCastStartInside() const
Whether the most recent cast began overlapping the solid.
float getCollisionX() const
X coordinate of the closest sampled point from the last collision check.
int getMoverIterations() const
Number of solver passes used by the most recent moveCapsule call.
float getShapeContactZ() const
Z coordinate on the sphere or capsule surface along the contact normal.
int getWidth() const
Number of grid vertices along the X axis.
float getNormalY() const
Y component of the most recently sampled collision normal.
bool didMoverHitWall() const
Whether the latest move encountered a non-walkable contact normal.
void setMoverSkinWidth(float width)
Set the non-negative separation retained from surfaces by moveCapsule.
float getSurfaceX() const
X coordinate of the projected signed-distance-field surface point.
float getCastFraction() const
Fraction in [0,1] of the requested displacement at the last cast hit.
float getMoverDeltaY() const
Resolved Y displacement from the most recent moveCapsule call.
void setDistance(int x, int y, int z, float distance)
Set a signed-distance sample at a grid vertex.
float getCollisionZ() const
Z coordinate of the closest sampled point from the last collision check.
float getShapeContactX() const
X coordinate on the sphere or capsule surface along the contact normal.
bool checkSphere(float x, float y, float z, float radius)
Test a sphere against the solid (distance <= radius).
float getPenetrationDepth() const
Non-negative overlap depth from the most recent overlap, cast, or move query.
float getSurfaceZ() const
Z coordinate of the projected signed-distance-field surface point.
float getSurfaceY() const
Y coordinate of the projected signed-distance-field surface point.
float getMoverNormalZ() const
Z component of the most recent blocking or recovery normal.
void setMoverStepHeight(float height)
Set the maximum non-negative ledge height automatically climbed by moveCapsule.
int getDepth() const
Number of grid vertices along the Z axis.
float getMoverSkinWidth() const
Current mover separation from collision surfaces.
float sample(float x, float y, float z) const
Trilinearly sample the field in world coordinates.
float getOriginZ() const
World-space Z coordinate of grid vertex (0,0,0).
float getDistance(int x, int y, int z) const
Read a grid vertex; out-of-range vertices return the outside distance.
float getMoverNormalY() const
Y component of the most recent blocking or recovery normal.
void destroy()
Destroys the fixture inside its world.
Definition Fixture.cpp:30
Body * getBody()
Returns the owning body, or null after invalidation.
Definition Fixture.h:77
void setSensor(bool sensor)
Sensor fixtures report contacts but never collide.
Definition Fixture.cpp:43
bool testPoint(float x, float y) const
Pixel-space point-in-fixture test (uses World meter).
Definition Fixture.cpp:105
int getMaskBits() const
Returns the mask bits.
Definition Fixture.cpp:90
int getCategoryBits() const
Returns the category bits.
Definition Fixture.cpp:79
void setMaskBits(int bits)
Sets the mask bits.
Definition Fixture.cpp:83
float getFriction() const
Returns the friction.
Definition Fixture.cpp:55
void setDensity(float density)
Sets the density.
Definition Fixture.cpp:64
bool isSensor() const
True when sensor.
Definition Fixture.cpp:48
void setFriction(float friction)
Material properties.
Definition Fixture.cpp:50
int getGroupIndex() const
Returns the group index.
Definition Fixture.cpp:99
int getBodyId() const
Id of the owning body.
Definition Fixture.cpp:103
void setCategoryBits(int bits)
Collision filtering (Box2D category/mask bits, group index).
Definition Fixture.cpp:72
void setGroupIndex(int index)
Sets the group index.
Definition Fixture.cpp:92
const std::string & getTag() const
Returns the tag.
Definition Fixture.h:51
float getDensity() const
Returns the density.
Definition Fixture.cpp:70
void setRestitution(float restitution)
Sets the restitution.
Definition Fixture.cpp:57
void setTag(const std::string &tag)
Arbitrary string tag surfaced in begin/end contact events.
Definition Fixture.h:49
float getRestitution() const
Returns the restitution.
Definition Fixture.cpp:62
Interactive 2D particle fluid (double-density relaxation) in pixel space. Script-owned; independent o...
Definition Fluid2D.h:19
void setViscosity(float viscosity)
Sets the viscosity.
Definition Fluid2D.cpp:47
float getNearPressureStiffness() const
Returns the near pressure stiffness.
Definition Fluid2D.h:57
float getParticleVy(int index) const
Returns the particle vy.
Definition Fluid2D.cpp:124
float getGravityY() const
Returns the gravity y.
Definition Fluid2D.h:37
void update(float dt)
Updates .
Definition Fluid2D.cpp:266
int getIterations() const
Returns the iterations.
Definition Fluid2D.h:67
void setIterations(int iterations)
Solver iterations per frame (default 3).
Definition Fluid2D.cpp:49
float getRestDensity() const
Returns the rest density.
Definition Fluid2D.h:47
float getGravityX() const
Returns the gravity x.
Definition Fluid2D.h:35
void setBounds(float x, float y, float w, float h)
Axis-aligned container; particles bounce inside.
Definition Fluid2D.cpp:51
int getParticleCount() const
Returns the particle count.
Definition Fluid2D.h:111
void setRestDensity(float density)
Target rest density for the relaxation solver (default 4).
Definition Fluid2D.cpp:38
void setGravity(float gx, float gy)
Sets the gravity.
Definition Fluid2D.cpp:28
void clear()
Clear all particles.
Definition Fluid2D.cpp:84
int emit(float x, float y, int count, float vx=0.f, float vy=0.f)
Spawn up to count particles at (x,y) with initial velocity. Returns number actually added.
Definition Fluid2D.cpp:65
float getSmoothingRadius() const
Returns the smoothing radius.
Definition Fluid2D.h:42
void destroy()
Destroys .
Definition Fluid2D.cpp:22
int getCapacity() const
Returns the capacity.
Definition Fluid2D.h:109
void setPressureStiffness(float k)
Pressure stiffness (default 0.5).
Definition Fluid2D.cpp:43
float getParticleY(int index) const
Returns the particle y.
Definition Fluid2D.cpp:114
void setParticleSize(float size)
Particle draw size in pixels (default 5).
Definition Fluid2D.cpp:103
void setSmoothingRadius(float radius)
Interaction / neighbor radius in pixels (default 18).
Definition Fluid2D.cpp:33
void draw(graphics::Graphics *gfx)
Draws .
Definition Fluid2D.cpp:329
float getParticleSize() const
Returns the particle size.
Definition Fluid2D.h:103
float getParticleVx(int index) const
Returns the particle vx.
Definition Fluid2D.cpp:119
void setNearPressureStiffness(float k)
Near-pressure (anti-clustering) stiffness (default 0.5).
Definition Fluid2D.cpp:45
float getViscosity() const
Returns the viscosity.
Definition Fluid2D.h:62
void setColor(float r, float g, float b, float a=1.f)
Sets the color.
Definition Fluid2D.cpp:96
void interactAt(float x, float y, float radius, float strength)
Mouse / pointer interaction: positive strength attracts, negative repels. Applied as acceleration wit...
Definition Fluid2D.cpp:89
void clearBounds()
Clears bounds.
Definition Fluid2D.cpp:63
float getPressureStiffness() const
Returns the pressure stiffness.
Definition Fluid2D.h:52
float getParticleX(int index) const
Returns the particle x.
Definition Fluid2D.cpp:109
void setWheelSpring(float frequencyHz, float dampingRatio)
Configures wheel suspension spring.
Definition Joint2D.cpp:213
void setGearRatio(float ratio)
Changes gear ratio.
Definition Joint2D.cpp:272
float getMotorAngularOffset() const
Motor angular offset in radians.
Definition Joint2D.cpp:267
Joint2D * getGearJoint1() const
First joint linked by a gear, or null.
Definition Joint2D.h:129
std::string getKind() const
Joint kind string for script/debug.
Definition Joint2D.cpp:76
float getRevoluteSpeed() const
Current revolute speed in radians/second.
Definition Joint2D.cpp:159
void setPrismaticMotor(bool enabled, float speedPixels, float maxForcePixels)
Configures a prismatic motor in pixels/second and pixel-force units.
Definition Joint2D.cpp:178
float getWeldFrequency() const
Weld spring frequency in Hertz.
Definition Joint2D.cpp:204
void setMotorAngularOffset(float radians)
Sets motor-joint angular offset in radians.
Definition Joint2D.cpp:246
float getDistanceLength() const
Distance-joint rest length in pixels.
Definition Joint2D.cpp:115
void destroy()
Destroys the backend joint and invalidates this wrapper.
Definition Joint2D.cpp:51
Joint2D * getGearJoint2() const
Second joint linked by a gear, or null.
Definition Joint2D.h:136
void setWeldSpring(float frequencyHz, float dampingRatio)
Configures weld rotational spring frequency and damping.
Definition Joint2D.cpp:196
float getMotorLinearOffsetX() const
Motor linear offset X in pixels.
Definition Joint2D.cpp:259
void setPrismaticLimits(bool enabled, float lowerPixels, float upperPixels)
Configures prismatic translation limits in pixels.
Definition Joint2D.cpp:168
void setCollideConnected(bool collide)
Enables or disables collision between the attached bodies.
Definition Joint2D.cpp:92
void setMotorLimits(float maxForcePixels, float maxTorque)
Sets motor max force (pixel-force) and torque (N·m).
Definition Joint2D.cpp:251
void setWheelMotor(bool enabled, float speed, float maxTorque)
Configures wheel spin motor in radians/second and newton-metres.
Definition Joint2D.cpp:221
float getPrismaticSpeed() const
Current prismatic speed in pixels/second.
Definition Joint2D.cpp:191
int getBodyBId() const
Stable ID of attached body B, or -1 after invalidation.
Definition Joint2D.cpp:90
void setDistanceSpring(float frequencyHz, float dampingRatio)
Configures distance spring frequency (Hz) and damping ratio.
Definition Joint2D.cpp:119
bool isValid() const
Whether the backend joint still exists.
Definition Joint2D.cpp:38
bool getCollideConnected() const
Whether attached bodies may collide.
Definition Joint2D.cpp:101
float getDistanceFrequency() const
Distance spring frequency in Hertz.
Definition Joint2D.cpp:127
float getWheelTranslation() const
Current wheel translation along the suspension axis in pixels.
Definition Joint2D.cpp:230
int getBodyAId() const
Stable ID of attached body A, or -1 after invalidation.
Definition Joint2D.cpp:89
int getId() const
Stable world-local identifier.
Definition Joint2D.h:38
void setRevoluteMotor(bool enabled, float speed, float maxTorque)
Configures the revolute motor in radians/second and newton-metres.
Definition Joint2D.cpp:146
float getRevoluteAngle() const
Current revolute angle in radians.
Definition Joint2D.cpp:155
float getMotorLinearOffsetY() const
Motor linear offset Y in pixels.
Definition Joint2D.cpp:263
void setRevoluteLimits(bool enabled, float lower, float upper)
Configures revolute angular limits in radians.
Definition Joint2D.cpp:136
float getGearRatio() const
Current gear ratio.
Definition Joint2D.cpp:278
float getWeldDampingRatio() const
Weld spring damping ratio.
Definition Joint2D.cpp:208
float getPrismaticTranslation() const
Current prismatic translation in pixels.
Definition Joint2D.cpp:187
void setDistanceLength(float lengthPixels)
Changes distance-joint rest length in pixels.
Definition Joint2D.cpp:110
float getWheelSpeed() const
Current wheel spin speed in radians/second.
Definition Joint2D.cpp:234
float getDistanceDampingRatio() const
Distance spring damping ratio.
Definition Joint2D.cpp:131
void setMotorLinearOffset(float xPixels, float yPixels)
Sets motor-joint linear offset in pixels (bodyA frame).
Definition Joint2D.cpp:239
float getRevoluteMotorTorque() const
Current revolute motor torque in newton-metres.
Definition Joint2D.cpp:163
float getConstraintForceX() const
Current world-space constraint force X in newtons.
void setDistanceLength(float length)
Changes distance-joint rest length in metres.
Definition Joint3D.cpp:119
float getConstraintForceY() const
Current world-space constraint force Y in newtons.
float getParallelHertz() const
Parallel spring stiffness in Hertz.
Definition Joint3D.cpp:442
void destroy()
Destroys the backend joint and invalidates this wrapper.
Definition Joint3D.cpp:48
void setForceThreshold(float threshold)
Sets the force threshold that emits a joint-stress event, in newtons.
Definition Joint3D.cpp:80
float getDistanceLength() const
Distance-joint rest length in metres.
Definition Joint3D.cpp:124
void setWheelSteering(bool enabled, float targetAngle, float hertz, float dampingRatio, float maxTorque)
Configures steering target, stiffness, damping and maximum torque.
Definition Joint3D.cpp:299
void setMotorVelocityLimits(float maxForce, float maxTorque)
Sets motor velocity force/torque limits.
Definition Joint3D.cpp:383
void setWheelSpinMotor(bool enabled, float speed, float maxTorque)
Configures wheel spin motor speed and maximum torque.
Definition Joint3D.cpp:291
void setSphericalTwistLimits(bool enabled, float lower, float upper)
Enables spherical twist limits in radians.
Definition Joint3D.cpp:244
float getTorqueThreshold() const
Current torque event threshold in newton-metres.
Definition Joint3D.cpp:93
float getParallelMaxTorque() const
Parallel maximum spring torque in newton-metres.
Definition Joint3D.cpp:450
float getWheelSpinTorque() const
Current wheel spin motor torque in newton-metres.
Definition Joint3D.cpp:325
void setRevoluteLimits(bool enabled, float lower, float upper)
Configures revolute angular limits in radians.
Definition Joint3D.cpp:169
void setDistanceMotor(bool enabled, float speed, float maxForce)
Configures the distance motor in metres/second and newtons.
Definition Joint3D.cpp:149
float getRevoluteMotorTorque() const
Current revolute motor torque in newton-metres.
Definition Joint3D.cpp:190
void setMotorAngularVelocity(float wx, float wy, float wz)
Sets motor-joint relative angular velocity in radians/second.
Definition Joint3D.cpp:376
float getForceThreshold() const
Current force event threshold in newtons.
Definition Joint3D.cpp:85
float getParallelDampingRatio() const
Parallel spring damping ratio.
Definition Joint3D.cpp:446
void setSphericalMotor(bool enabled, float velocityX, float velocityY, float velocityZ, float maxTorque)
Configures spherical motor velocity and maximum torque.
Definition Joint3D.cpp:254
float getWeldAngularHertz() const
Weld angular stiffness in Hertz.
Definition Joint3D.cpp:360
float getWeldLinearDampingRatio() const
Weld linear damping ratio.
Definition Joint3D.cpp:356
void setTorqueThreshold(float threshold)
Sets the torque threshold that emits a joint-stress event, in newton-metres.
Definition Joint3D.cpp:88
void setWeldLinearSpring(float hertz, float dampingRatio)
Configures weld linear spring stiffness and damping; 0 hertz is rigid.
Definition Joint3D.cpp:338
float getDistanceCurrentLength() const
Current anchor-to-anchor distance in metres.
Definition Joint3D.cpp:128
float getPrismaticTranslation() const
Current prismatic translation in metres.
Definition Joint3D.cpp:223
float getRevoluteAngle() const
Current revolute angle in radians.
Definition Joint3D.cpp:186
void setDistanceLimits(bool enabled, float minimum, float maximum)
Configures optional distance limits in metres.
Definition Joint3D.cpp:140
float getConstraintTorqueZ() const
Current world-space constraint torque Z in newton-metres.
float getWheelSpinSpeed() const
Current wheel spin speed in radians/second.
Definition Joint3D.cpp:321
int getId() const
Stable world-local identifier.
Definition Joint3D.h:35
void setWheelSteeringLimits(bool enabled, float lower, float upper)
Configures steering angular limits in radians.
Definition Joint3D.cpp:312
float getPrismaticMotorForce() const
Current prismatic motor force in newtons.
Definition Joint3D.cpp:231
void setRevoluteSpring(bool enabled, float targetAngle, float hertz, float dampingRatio)
Configures a revolute angular spring in radians.
Definition Joint3D.cpp:158
void setPrismaticLimits(bool enabled, float lower, float upper)
Configures prismatic translation limits in metres.
Definition Joint3D.cpp:206
std::string getKind() const
Joint kind string for script/debug ("distance", "revolute", …, "filter").
Definition Joint3D.cpp:54
float getMotorLinearVelocityX() const
Desired motor linear velocity X in metres/second.
Definition Joint3D.cpp:408
void setParallelSpring(float hertz, float dampingRatio, float maxTorque)
Configures parallel-joint spring stiffness, damping and torque cap.
Definition Joint3D.cpp:433
void setMotorLinearVelocity(float vx, float vy, float vz)
Sets motor-joint relative linear velocity in metres/second.
Definition Joint3D.cpp:369
float getMotorAngularVelocityY() const
Desired motor angular velocity Y in radians/second.
Definition Joint3D.cpp:424
float getLinearSeparation() const
Current inadmissible linear separation error in metres.
Definition Joint3D.cpp:107
float getMotorAngularVelocityX() const
Desired motor angular velocity X in radians/second.
Definition Joint3D.cpp:420
float getWheelSteeringTorque() const
Current steering torque in newton-metres.
Definition Joint3D.cpp:333
float getMotorAngularVelocityZ() const
Desired motor angular velocity Z in radians/second.
Definition Joint3D.cpp:428
float getWeldLinearHertz() const
Weld linear stiffness in Hertz.
Definition Joint3D.cpp:352
float getWeldAngularDampingRatio() const
Weld angular damping ratio.
Definition Joint3D.cpp:364
float getConstraintTorqueX() const
Current world-space constraint torque X in newton-metres.
float getConstraintForceZ() const
Current world-space constraint force Z in newtons.
float getMotorLinearVelocityY() const
Desired motor linear velocity Y in metres/second.
Definition Joint3D.cpp:412
float getAngularSeparation() const
Current inadmissible angular separation error in radians.
Definition Joint3D.cpp:110
float getMotorLinearVelocityZ() const
Desired motor linear velocity Z in metres/second.
Definition Joint3D.cpp:416
float getWheelSteeringAngle() const
Current wheel steering angle in radians.
Definition Joint3D.cpp:329
void setDistanceSpring(bool enabled, float hertz, float dampingRatio)
Configures a distance spring; hertz and damping must be non-negative.
Definition Joint3D.cpp:132
void setRevoluteMotor(bool enabled, float speed, float maxTorque)
Configures the revolute motor in radians/second and newton-metres.
Definition Joint3D.cpp:178
int getBodyAId() const
Stable ID of attached body A, or -1 after invalidation.
Definition Joint3D.cpp:69
void setWheelSuspensionLimits(bool enabled, float lower, float upper)
Configures wheel suspension travel limits in metres.
Definition Joint3D.cpp:282
float getPrismaticSpeed() const
Current prismatic translation speed in metres/second.
Definition Joint3D.cpp:227
bool getCollideConnected() const
Whether attached bodies may collide.
Definition Joint3D.cpp:76
void setMotorAngularSpring(float hertz, float dampingRatio, float maxTorque)
Configures motor angular position spring.
Definition Joint3D.cpp:399
float getSphericalConeAngle() const
Current spherical cone angle in radians.
Definition Joint3D.cpp:265
void setPrismaticMotor(bool enabled, float speed, float maxForce)
Configures a prismatic motor in metres/second and newtons.
Definition Joint3D.cpp:215
void setSphericalConeLimit(bool enabled, float angle)
Enables a spherical cone limit in radians, within [0, pi].
Definition Joint3D.cpp:236
void setWeldAngularSpring(float hertz, float dampingRatio)
Configures weld angular spring stiffness and damping; 0 hertz is rigid.
Definition Joint3D.cpp:345
int getBodyBId() const
Stable ID of attached body B, or -1 after invalidation.
Definition Joint3D.cpp:70
void setWheelSuspension(bool enabled, float hertz, float dampingRatio)
Configures wheel suspension spring stiffness and damping.
Definition Joint3D.cpp:274
void setPrismaticSpring(bool enabled, float targetTranslation, float hertz, float dampingRatio)
Configures a prismatic linear spring and target translation.
Definition Joint3D.cpp:195
float getConstraintTorqueY() const
Current world-space constraint torque Y in newton-metres.
float getSphericalTwistAngle() const
Current spherical twist angle in radians.
Definition Joint3D.cpp:269
void setCollideConnected(bool collide)
Enables or disables collision between the attached bodies.
Definition Joint3D.cpp:72
void setMotorLinearSpring(float hertz, float dampingRatio, float maxForce)
Configures motor linear position spring.
Definition Joint3D.cpp:390
Joint2D * getSliderJoint() const
Frame-to-slider prismatic, or null for shaft/ratchet.
Definition Mechanism2D.h:74
float getRatchetEngagementTorque() const
Current ratchet engagement torque in newton-metres.
void setRatchetDirection(int direction)
Sets ratchet freewheel direction (+1 or -1).
std::string getKind() const
Kind name: "crankSlider", "shaft", or "ratchet".
float getSpinSpeed() const
Relative spin speed in radians/second.
float getDriveAngle() const
Current drive revolute angle in radians.
void clearDrive()
Disables the continuous drive motor.
int getRatchetDirection() const
Current ratchet freewheel direction (+1 or -1).
Definition Mechanism2D.h:97
void setRatchetEngagementTorque(float torque)
Sets reverse-lock torque for ratchet engagement.
Joint2D * getDriveJoint() const
Primary revolute (crank / shaft / ratchet wheel).
Definition Mechanism2D.h:53
int getId() const
Stable world-local identifier.
Definition Mechanism2D.h:34
float getSliderTranslation() const
Current slider translation in pixels (crank-slider only).
Joint2D * getCrankPinJoint() const
Crank-to-rod revolute, or null for shaft/ratchet.
Definition Mechanism2D.h:60
void setDrive(float speed, float maxTorque)
Enables a continuous drive motor on the primary revolute.
bool isValid() const
Whether the assembly and its primary joints are still live.
Joint2D * getSliderPinJoint() const
Rod-to-slider revolute, or null for shaft/ratchet.
Definition Mechanism2D.h:67
void destroy()
Destroys owned joints and invalidates this wrapper.
bool isDriveEnabled() const
Whether a continuous drive motor is configured.
Definition Mechanism2D.h:92
Joint3D * getCrankPinJoint() const
Crank-to-rod revolute, or null for shaft/ratchet.
Definition Mechanism3D.h:55
float getSliderTranslation() const
Current slider translation in metres (crank-slider only).
void setRatchetEngagementTorque(float torque)
Sets reverse-lock torque for ratchet engagement.
void destroy()
Destroys owned joints and invalidates this wrapper.
void setRatchetDirection(int direction)
Sets ratchet freewheel direction.
float getDriveAngle() const
Current drive revolute angle in radians (shaft/crank/ratchet).
void setDrive(float speed, float maxTorque)
Enables a continuous drive motor on the primary revolute.
Joint3D * getSliderPinJoint() const
Rod-to-slider revolute, or null for shaft/ratchet.
Definition Mechanism3D.h:62
int getId() const
Stable world-local identifier.
Definition Mechanism3D.h:34
bool isValid() const
Whether the assembly and its primary joints are still live.
int getRatchetDirection() const
Current ratchet freewheel direction (+1 or -1).
Definition Mechanism3D.h:96
std::string getKind() const
Kind name: "crankSlider", "shaft", or "ratchet".
float getRatchetEngagementTorque() const
Current ratchet engagement torque in newton-metres.
bool isDriveEnabled() const
Whether a continuous drive motor is configured.
Definition Mechanism3D.h:88
void clearDrive()
Disables the continuous drive motor.
Joint3D * getDriveJoint() const
Primary revolute (crank / shaft / ratchet wheel).
Definition Mechanism3D.h:48
Joint3D * getSliderJoint() const
Frame-to-slider prismatic, or null for shaft/ratchet.
Definition Mechanism3D.h:69
float getSpinSpeed() const
Relative spin speed along the drive axis in radians/second.
Physics module — Box2D (2D) + Box3D (3D) rigid bodies and SPH fluid. Script: physics <- eve....
Definition Physics.h:22
DistanceField3D * newDistanceField3D(int width, int height, int depth, float cellSize, float originX=0.f, float originY=0.f, float originZ=0.f, float outsideDistance=1e6f)
Create a regular 3D signed-distance grid for map collision queries.
Definition Physics.cpp:49
World3D * newWorld3D(float gravityX, float gravityY, float gravityZ, bool sleep=true)
Create a 3D Box3D physics world. Coordinates are meters (Box3D native); +Y is up by convention.
Definition Physics.cpp:45
void setMeter(float pixelsPerMeter)
Pixels per meter for 2D Box2D worlds (default 30, same as LÖVE).
Definition Physics.cpp:33
SoftBody3DRenderer * newSoftBody3DRenderer(SoftBody3D *body)
Create a presentation satellite observing a soft-body runtime.
Definition Physics.cpp:63
Fluid2D * newFluid2D(int capacity=512)
Creates an interactive 2D particle fluid in pixel space.
Definition Physics.cpp:67
float getMeter() const
Returns the meter.
Definition Physics.cpp:39
World * newWorld(float gravityX, float gravityY, bool sleep=true)
Create a 2D Box2D physics world.
Definition Physics.cpp:41
SoftBody3D * newSoftBody3D(int cols, int rows, int layers, float spacing, float originX, float originY, float originZ)
Compatibility factory for a volumetric shape-matching soft body.
Definition Physics.cpp:56
int getId() const
Stable world-local id, preserved when sensor state recreates the backend shape.
Definition Shape3D.h:44
float getHeightFieldCellSizeZ() const
Height-field cell spacing along local Z, or zero.
Definition Shape3D.h:149
void setLocalPosition(float x, float y, float z)
Sets local translation while preserving local rotation.
Definition Shape3D.cpp:764
void setDensity(float density)
Definition Shape3D.cpp:882
void setTag(int tag)
User-defined integer tag preserved for the wrapper lifetime.
Definition Shape3D.cpp:383
void setBoxSize(float width, float height, float depth)
Atomically changes full box dimensions in meters.
Definition Shape3D.cpp:469
int getHeightFieldCountZ() const
Height-field sample count along local Z, or zero.
Definition Shape3D.h:143
float getTriangleMeshMaterialRestitution(int slot) const
Restitution of a triangle-mesh material slot.
Definition Shape3D.cpp:659
int getTriangleMeshMaterialId(int slot) const
Application material ID of a triangle-mesh material slot.
Definition Shape3D.cpp:673
void setOneWay(float nx, float ny, float nz, float planeOffset, float margin, float minNormalDot)
Enables a one-way collision plane in shape-local space.
Definition Shape3D.cpp:398
float getLocalZ() const
Local translation Z in meters.
Definition Shape3D.h:209
int getTriangleMeshVertexCount() const
Source vertex count for a triangle mesh, or zero.
Definition Shape3D.h:94
std::string getKind() const
Kind name including primitives, "convexHull", "triangleMesh", or "heightField".
Definition Shape3D.cpp:457
bool testPoint(float x, float y, float z) const
Point-in-shape test in world meters.
Definition Shape3D.cpp:932
void setHitEventsEnabled(bool enabled)
Enables significant collision hit events for this shape.
Definition Shape3D.cpp:388
void setMaterialId(int id)
Sets a low-32-bit application material identifier exposed by native queries.
Definition Shape3D.cpp:829
int getTriangleMeshMaterialIndex(int triangleIndex) const
Material-slot index assigned to a source triangle.
Definition Shape3D.cpp:608
float getLocalRotX() const
Normalized local quaternion X.
Definition Shape3D.h:211
int getTag() const
User-defined integer tag, zero by default.
Definition Shape3D.h:50
void setTriangleMeshMaterial(int slot, float friction, float restitution, float rollingResistance, float tangentX, float tangentY, float tangentZ, int materialId, const std::string &frictionMode, const std::string &restitutionMode)
Replaces one triangle-mesh material slot without rebuilding geometry.
Definition Shape3D.cpp:622
float getHeightFieldHeight(int x, int z) const
Source height at a grid sample.
Definition Shape3D.cpp:719
int getTriangleMeshMaterialCount() const
Number of material slots on a triangle mesh, otherwise zero.
Definition Shape3D.cpp:618
float getTangentVelocityY() const
Local-space conveyor velocity Y component.
Definition Shape3D.cpp:821
float getTriangleMeshMaterialRollingResistance(int slot) const
Rolling resistance of a triangle-mesh material slot.
Definition Shape3D.cpp:665
bool isSensor() const
Definition Shape3D.cpp:772
void setRestitution(float restitution)
Definition Shape3D.cpp:783
float getLocalY() const
Local translation Y in meters.
Definition Shape3D.h:207
void setSphereRadius(float radius)
Atomically changes sphere radius in meters.
Definition Shape3D.cpp:488
float getBoxHeight() const
Full box height, or zero for another geometry kind.
Definition Shape3D.h:163
float getLocalX() const
Local translation X in meters.
Definition Shape3D.h:205
bool isOneWay() const
Whether one-way pre-solve filtering is requested.
Definition Shape3D.h:187
void setLocalTransform(float px, float py, float pz, float qx, float qy, float qz, float qw)
Atomically sets the shape transform relative to its Body3D.
Definition Shape3D.cpp:728
void setGroupIndex(int index)
Collision group; negative never collides, positive always collides.
Definition Shape3D.cpp:921
float getTriangleMeshMaterialFriction(int slot) const
Friction of a triangle-mesh material slot.
Definition Shape3D.cpp:653
float getBoxWidth() const
Full box width, or zero for another geometry kind.
Definition Shape3D.h:161
float getHeightFieldGlobalMin() const
Height-field shared quantization minimum, or zero.
Definition Shape3D.h:153
float getFriction() const
Definition Shape3D.cpp:781
float getRestitution() const
Definition Shape3D.cpp:790
void setFrictionCombineMode(const std::string &mode)
Sets friction combine mode: default, average, minimum, multiply, or maximum.
Definition Shape3D.cpp:837
void destroy()
Destroys the shape inside its world.
Definition Shape3D.cpp:240
void setLocalRotation(float qx, float qy, float qz, float qw)
Sets local rotation while preserving local translation.
Definition Shape3D.cpp:768
float getLocalRotW() const
Normalized local quaternion scalar component.
Definition Shape3D.h:217
void setTangentVelocity(float x, float y, float z)
Sets local-space conveyor velocity projected onto contact surfaces.
Definition Shape3D.cpp:808
float getExplosionScale() const
Current explosion impulse multiplier; zero opts this shape out.
Definition Shape3D.h:249
int getMaterialId() const
Low-32-bit application material identifier.
Definition Shape3D.cpp:867
float getCapsuleHeight() const
Capsule hemisphere-center distance, or zero for another kind.
Definition Shape3D.h:171
float getBoxDepth() const
Full box depth, or zero for another geometry kind.
Definition Shape3D.h:165
int getHeightFieldCountX() const
Height-field sample count along local X, or zero.
Definition Shape3D.h:141
void setCapsuleSize(float height, float radius)
Atomically changes capsule segment height and radius in meters.
Definition Shape3D.cpp:501
float getHeightFieldCellSizeX() const
Height-field cell spacing along local X, or zero.
Definition Shape3D.h:145
float getDensity() const
Definition Shape3D.cpp:889
int getGroupIndex() const
Definition Shape3D.cpp:928
float getLocalRotZ() const
Normalized local quaternion Z.
Definition Shape3D.h:215
float getHeightFieldGlobalMax() const
Height-field shared quantization maximum, or zero.
Definition Shape3D.h:157
void setRestitutionCombineMode(const std::string &mode)
Sets restitution combine mode: default, average, minimum, multiply, or maximum.
Definition Shape3D.cpp:852
float getTangentVelocityZ() const
Local-space conveyor velocity Z component.
Definition Shape3D.cpp:825
int getTriangleMeshTriangleCount() const
Source triangle count for a triangle mesh, or zero.
Definition Shape3D.h:98
std::string getRestitutionCombineMode() const
Current restitution combine mode.
Definition Shape3D.cpp:861
void setRollingResistance(float resistance)
Rolling resistance coefficient, finite and non-negative.
Definition Shape3D.cpp:794
void disableOneWay()
Disables one-way filtering and restores ordinary two-sided collision.
Definition Shape3D.cpp:422
void setSensor(bool sensor)
Sensor shapes report contacts but never collide.
Definition Shape3D.cpp:371
int getConvexHullPointCount() const
Source point count for a convex hull, or zero for another kind.
Definition Shape3D.h:78
float getLocalRotY() const
Normalized local quaternion Y.
Definition Shape3D.h:213
std::string getFrictionCombineMode() const
Current friction combine mode.
Definition Shape3D.cpp:846
bool areHitEventsEnabled() const
Whether significant collision hit events are enabled.
Definition Shape3D.cpp:394
void setFriction(float friction)
Material properties.
Definition Shape3D.cpp:774
void setExplosionScale(float scale)
Sets non-negative multiplier applied to geometry-aware explosion impulses.
Definition Shape3D.cpp:874
float getRadius() const
Sphere/capsule radius, or zero for a box.
Definition Shape3D.h:167
int getConvexHullMaxVertices() const
Current convex-hull simplification budget, or zero for another kind.
Definition Shape3D.h:82
float getTangentVelocityX() const
Local-space conveyor velocity X component.
Definition Shape3D.cpp:817
float getRollingResistance() const
Current rolling resistance; physically affects spheres and capsules.
Definition Shape3D.cpp:804
Presentation-only renderer for a borrowed volumetric soft body.
void draw(graphics::Graphics *graphics)
Update the surface cache and draw it in the current 3D frame.
void setBody(SoftBody3D *body)
Replace the borrowed runtime; null disables drawing.
void setColor(float r, float g, float b, float a)
Set the clamped RGBA presentation color.
Volumetric particle soft body using overlapping shape-matching clusters.
Definition SoftBody3D.h:27
World3D * getCollideWorld() const
Returns the collide world.
int getParticleCount() const
Definition SoftBody3D.h:174
void applyForce(float x, float y, float z)
Applies force.
void pin(int index)
Pin.
void setParticleMass(float value)
Sets the particle mass.
float getGravityY() const
Returns the gravity y.
Definition SoftBody3D.h:81
float getParticleMass() const
Returns the particle mass.
Definition SoftBody3D.h:103
void releaseGrab()
Release grab.
Definition SoftBody3D.h:134
void update(float dt)
Advances using a legacy variable timestep clamped to 50 ms.
float getGravityZ() const
Returns the gravity z.
Definition SoftBody3D.h:83
void setBounds(float x, float y, float z, float width, float height, float depth)
Sets the bounds.
float getParticleZ(int index) const
void setIterations(int value)
Sets the iterations.
bool getSelfCollision() const
Returns the self collision.
Definition SoftBody3D.h:117
void setDeformationResistance(float value)
Sets the deformation resistance.
void setCollideWorld(World3D *world)
Borrows a rigid-body world used for particle contacts.
float getPlasticCreep() const
Returns the plastic creep.
float getMaxDeformation() const
Returns the max deformation.
float getVolumeRatio() const
Returns current cell volume divided by undeformed rest volume.
float getPlasticYield() const
Returns the plastic yield.
void moveGrab(float x, float y, float z)
Moves grab.
int getIterations() const
Returns the iterations.
Definition SoftBody3D.h:91
void setGravity(float x, float y, float z)
Sets the gravity.
void setPlasticity(float yield, float creep, float recovery, float maxDeformation)
Sets the plasticity.
void setParticlePosition(int index, float x, float y, float z)
float getDeformationResistance() const
Returns the deformation resistance.
static eve::Result< std::unique_ptr< SoftBody3D > > create(const SoftBody3DDefinition &definition)
Creates a soft body from the canonical versioned definition.
void interactAt(float x, float y, float z, float radius, float strength)
Interact at.
bool isGrabbing() const
True when grabbing.
Definition SoftBody3D.h:136
int getGrabIndex() const
Returns the grab index.
Definition SoftBody3D.h:138
float getDamping() const
Returns the damping.
Definition SoftBody3D.h:95
float getPlasticRecovery() const
Returns the plastic recovery.
void setParticleRadius(float value)
Sets the particle radius.
void clearBounds()
Clears bounds.
Definition SoftBody3D.h:121
void setDamping(float value)
Sets the damping.
bool isPinned(int index) const
True when pinned.
float getParticleX(int index) const
float getParticleY(int index) const
int grabAt(float x, float y, float z, float radius)
Grab at.
void unpin(int index)
Unpin.
float getGravityX() const
Returns the gravity x.
Definition SoftBody3D.h:79
void destroy()
Destroys .
void setSelfCollision(bool enabled)
Sets the self collision.
Definition SoftBody3D.h:115
float getParticleRadius() const
Returns the particle radius.
Caller-owned state for Pcg-style rigid-body activation after terrain loading.
bool isCompleted() const
Whether gravity restoration and the activation notification completed.
bool isMonitoring() const
Whether a containing terrain was found and activation is being monitored.
bool isActivationScheduled() const
Whether the post-load delay has been scheduled.
float getDelayElapsed() const
Elapsed seconds since the first loaded observation.
Box3D rigid-body world. Script coordinates are meters (Box3D native), unlike 2D World which uses pixe...
Definition World3D.h:63
bool hasClosestPoint() const
Whether the latest closestPoint call found a shape.
Definition World3D.h:655
int getBeginTriggerVisitorShapeId(int index) const
Visitor shape ID of a begin-trigger event.
float getProfileStepMs() const
Latest complete physics step time in milliseconds.
float getRestitutionThreshold() const
Current restitution speed threshold in m/s.
Definition World3D.cpp:235
void setGravity(float gx, float gy, float gz)
Gravity in m/s².
Definition World3D.cpp:775
int getBeginContactShapeAId(int index) const
Shape ID on stable side A of a begin-contact event.
float getShapeCastX() const
World-space contact point X from the last shape cast.
Definition World3D.h:690
int getEndTriggerCount() const
Number of sensor overlaps that ended during the latest step.
Definition World3D.h:828
int getQueryBodyId(int index) const
Body id of the i-th query hit.
Definition World3D.cpp:2074
float getJointStressForceY(int index) const
Constraint force Y of a stress event.
int getClosestShapeId() const
Stable shape id from the latest closestPoint call, or -1.
Definition World3D.h:659
float getContactPointTotalNormalImpulse(int index) const
Total normal impulse accumulated across all physics substeps.
int getRayHitTriangleIndex() const
Mesh/height-field triangle index from the last ray cast, otherwise -1.
Definition World3D.h:523
float getHitNormalX(int index) const
Hit normal X, pointing from stable side A to B.
int getDynamicTreeHeight() const
Dynamic broad-phase tree height.
int castSphere(float x, float y, float z, float radius, float dx, float dy, float dz)
Sweep a sphere through the world and return the earliest hit body id, or -1.
Definition World3D.cpp:1788
bool hasRayHit() const
Definition World3D.h:514
bool isWarmStartingEnabled() const
Whether constraint warm starting is enabled.
Definition World3D.cpp:276
int getShapeCastResultShapeId(int index) const
Shape ID of a sorted Shape Cast result.
float getMaximumLinearSpeed() const
Current world-wide maximum linear speed in m/s.
Definition World3D.cpp:268
float getClosestY() const
Closest surface point Y.
Definition World3D.h:665
int getBeginTriggerSensorBodyId(int index) const
Sensor body ID of a begin-trigger event.
float getHitPointZ(int index) const
World-space impact point Z.
int getAwakeBodyCount() const
Number of awake bodies.
Definition World3D.cpp:388
Joint3D * newMotorJoint(Body3D *bodyA, Body3D *bodyB, bool collideConnected=false)
Creates a motor joint that drives relative linear/angular velocity between bodies.
float getContactPushOutSpeed() const
Current maximum contact push-out speed in m/s.
Definition World3D.h:222
int queryCapsule(float ax, float ay, float az, float bx, float by, float bz, float radius)
Query shapes overlapping an arbitrarily oriented capsule. The endpoints are the centers of its hemisp...
Definition World3D.cpp:1636
float getContactPointNormalImpulse(int index) const
Normal impulse from the final physics substep.
int getEndContactShapeBId(int index) const
Shape ID on stable side B of an end-contact event.
void update(float dt)
Steps the simulation by dt seconds (default substep count).
Definition World3D.cpp:726
int closestPoint(float x, float y, float z, float maxDistance)
Find the closest collision surface within maxDistance of a world point. Uses the current query catego...
Definition World3D.cpp:1838
float getShapeCastResultFraction(int index) const
Translation fraction in [0,1] of a Shape Cast result.
int getClosestShapeTag() const
User tag of the shape from the latest closestPoint call, or zero.
Definition World3D.h:661
int getEndContactBodyAId(int index) const
Body ID on stable side A of an end-contact event.
int getEndContactShapeATag(int index) const
Shape Tag on stable side A of an end-contact event.
int getJointCount() const
Current backend joint count.
int getShapeCastShapeId() const
Stable shape id from the last shape cast, or -1.
Definition World3D.h:682
int getRayResultTriangleIndex(int index) const
Mesh/height-field triangle index of a sorted ray result, otherwise -1.
float getRayHitX() const
Definition World3D.h:524
float getShapeCastZ() const
World-space contact point Z from the last shape cast.
Definition World3D.h:694
float getContactPointX(int index) const
World-space contact point X on the queried body.
int castBox(float x, float y, float z, float width, float height, float depth, float qx, float qy, float qz, float qw, float dx, float dy, float dz)
Sweep an oriented box without changing its rotation.
Definition World3D.cpp:1820
int getBeginContactBodyBId(int index) const
Body ID on stable side B of a begin-contact event.
float getRayHitY() const
Definition World3D.h:525
int getContactPointOtherShapeId(int index) const
Other Shape ID of a contact point.
float getContactDampingRatio() const
Current contact damping ratio.
Definition World3D.h:220
float getMoverNormalY() const
Representative blocking normal Y from the last move.
Definition World3D.h:757
int getQueryShapeCount() const
Number of individual shapes hit by the last overlap query.
Definition World3D.h:778
Joint3D * newWeldJoint(Body3D *bodyA, Body3D *bodyB, float anchorX, float anchorY, float anchorZ, bool collideConnected=false)
Welds two bodies at a shared world-space anchor, preserving current relative pose.
float getBoundsMinZ() const
Minimum world-space Z covered by current broad-phase bounds.
Definition World3D.cpp:360
float getExplosionResultDeltaVelocityX(int index) const
Explosion-induced linear velocity delta X.
int getQueryShapeId(int index) const
Stable shape id of the i-th shape hit, sorted ascending.
Definition World3D.cpp:2182
float getGravityX() const
Definition World3D.cpp:780
int getQueryCount() const
Number of bodies hit by the last overlap query.
Definition World3D.h:774
float getRayResultNormalY(int index) const
Surface normal Y of a sorted ray result.
float getProfileBulletsMs() const
Latest continuous-collision bullet time in milliseconds.
void setBodyPairCollisionEnabled(Body3D *bodyA, Body3D *bodyB, bool enabled)
Overrides collision for a live body pair without changing layer masks.
Definition World3D.cpp:810
float getContactHertz() const
Current contact stiffness frequency.
Definition World3D.h:218
float getRayHitNormalX() const
Definition World3D.h:527
float getContactPointSeparation(int index) const
Signed surface separation; negative values indicate penetration.
int getHitShapeBId(int index) const
Stable Shape ID on side B of a hit.
float getClosestNormalX() const
Surface-to-target normal X, or zero for an inside/on-surface target.
Definition World3D.h:669
int getQueryMaskBits() const
Query mask bits currently in use.
Definition World3D.h:945
int getQueryShapeTag(int index) const
User tag paired with the i-th shape hit.
Definition World3D.cpp:2188
Joint3D * newParallelJoint(Body3D *bodyA, Body3D *bodyB, float axisX, float axisY, float axisZ, bool collideConnected=false)
Creates a parallel joint that spring-aligns body local Z axes to a world axis.
float getMoverDeltaZ() const
Resolved translation Z from the last moveCapsule call.
Definition World3D.h:753
float getProfileCollideMs() const
Latest narrow-phase collision time in milliseconds.
void setMoverUp(float x, float y, float z)
Set the up direction used for grounded and slope classification.
Definition World3D.cpp:1918
int getHitCount() const
Number of significant collision hits generated during the latest step.
Definition World3D.h:887
Joint3D * newSphericalJoint(Body3D *bodyA, Body3D *bodyB, float anchorX, float anchorY, float anchorZ, float axisX, float axisY, float axisZ, bool collideConnected=false)
Creates a ball-and-socket joint with a world-space twist/cone axis.
Definition World3D.cpp:632
int getJointStressKind(int index) const
Joint kind code: 0 distance, 1 revolute, 2 prismatic, 3 spherical, 4 wheel.
int getShapeCastShapeTag() const
User tag of the shape from the last shape cast, or zero on no hit.
Definition World3D.h:684
float getRayHitNormalZ() const
Definition World3D.h:529
Joint3D * newRevoluteJoint(Body3D *bodyA, Body3D *bodyB, float anchorX, float anchorY, float anchorZ, float axisX, float axisY, float axisZ, bool collideConnected=false)
Creates a hinge around a normalized world-space axis at a shared anchor.
Definition World3D.cpp:562
float getMoverDeltaY() const
Resolved translation Y from the last moveCapsule call.
Definition World3D.h:751
float getHitPointX(int index) const
World-space impact point X.
int getBeginTriggerCount() const
Number of sensor overlaps that began during the latest step.
Definition World3D.h:814
void setContactTuning(float hertz, float dampingRatio, float pushOutSpeed)
Configures contact overlap recovery.
Definition World3D.cpp:239
bool isBodyPairCollisionEnabled(Body3D *bodyA, Body3D *bodyB) const
Whether a body pair is permitted by the runtime contact override.
Definition World3D.cpp:827
int queryBodyContacts(int bodyId, int maxPoints)
Caches current touching manifold points for one stable Body3D ID. Results are oriented from the queri...
Definition World3D.cpp:1096
void setQueryIgnoredBodyId(int bodyId)
Ignores one stable Body3D ID in subsequent spatial queries; -1 disables.
Definition World3D.cpp:980
int getExplosionResultBodyId(int index) const
Stable Body ID of an affected body, sorted ascending.
int getQueryCategoryBits() const
Query category bits currently in use.
Definition World3D.h:943
int castCapsule(float ax, float ay, float az, float bx, float by, float bz, float radius, float dx, float dy, float dz)
Sweep an arbitrarily oriented capsule through the world. The endpoints are cap centers and d{x,...
Definition World3D.cpp:1803
float getMoverNormalZ() const
Representative blocking normal Z from the last move.
Definition World3D.h:759
int getBeginTriggerVisitorShapeTag(int index) const
Visitor Shape Tag of a begin-trigger event.
int getEndContactShapeBTag(int index) const
Shape Tag on stable side B of an end-contact event.
float getClosestDistance() const
Non-negative distance from the target to the closest shape.
Definition World3D.h:675
int getHitBodyBId(int index) const
Stable body ID on side B of a hit.
bool isContinuousCollisionEnabled() const
Whether world-level continuous collision is enabled.
Definition World3D.cpp:225
int getContactPointShapeTag(int index) const
Queried-body Shape Tag of a contact point.
float getHitNormalImpulse(int index) const
Total normal impulse accumulated across all manifolds and substeps.
int querySphere(float x, float y, float z, float radius)
Query shapes overlapping a sphere in world meters.
Definition World3D.cpp:1627
int getHitShapeAId(int index) const
Stable Shape ID on side A of a hit.
float getShapeCastNormalZ() const
Contact normal Z from the last shape cast.
Definition World3D.h:700
void setWarmStartingEnabled(bool enabled)
Enables constraint warm starting for stable stacks and joints.
Definition World3D.cpp:272
float getContactPointY(int index) const
World-space contact point Y on the queried body.
float getContactPointNormalY(int index) const
Contact normal Y from queried body toward the other body.
int getBeginContactCount() const
Number of non-sensor contacts that began during the latest step.
Definition World3D.h:785
int getJointStressBodyAId(int index) const
Stable body A ID of a stress event.
float getGravityY() const
Definition World3D.cpp:785
float getShapeCastResultNormalZ(int index) const
Contact normal Z of a Shape Cast result.
int getEndContactCount() const
Number of non-sensor contacts that ended during the latest step.
Definition World3D.h:799
int getRayResultShapeId(int index) const
Shape ID of a sorted ray result.
bool isShapePairCollisionEnabled(Shape3D *shapeA, Shape3D *shapeB) const
Whether a shape pair is permitted by the runtime contact override.
Definition World3D.cpp:849
int castCapsuleAll(float ax, float ay, float az, float bx, float by, float bz, float radius, float dx, float dy, float dz, int maxHits)
Collects the nearest maxHits swept-capsule intersections.
Definition World3D.cpp:1809
int getBeginTriggerSensorShapeId(int index) const
Sensor shape ID of a begin-trigger event.
int rayCast(float x1, float y1, float z1, float x2, float y2, float z2)
Closest raycast from (x1,y1,z1) to (x2,y2,z2) in meters. Returns hit body id, or -1....
Definition World3D.cpp:1332
int getJointStressCount() const
Number of joints exceeding force/torque thresholds in the latest step.
Definition World3D.h:917
float getShapeCastResultY(int index) const
World-space contact point Y of a Shape Cast result.
int explode(float x, float y, float z, float radius, float falloff, float impulsePerArea, int maskBits=-1)
Applies a geometry-aware radial impulse to dynamic convex shapes.
Definition World3D.cpp:280
int getShapeCastTriangleIndex() const
Mesh/height-field triangle index from the latest shape cast, otherwise -1.
Definition World3D.h:688
void setQueryFilter(int categoryBits, int maskBits)
Set category/mask bits for subsequent ray, overlap, cast and mover queries.
Definition World3D.cpp:970
float getMoverDeltaX() const
Resolved translation X from the last moveCapsule call.
Definition World3D.h:749
int getShapeCastMaterialId() const
Surface material ID at the last shape-cast intersection, or zero.
Definition World3D.h:686
float getRayResultFraction(int index) const
Segment fraction in [0,1] of a sorted ray result.
float getClosestZ() const
Closest surface point Z.
Definition World3D.h:667
float getBoundsMaxZ() const
Maximum world-space Z covered by current broad-phase bounds.
Definition World3D.cpp:369
int getEndTriggerSensorShapeTag(int index) const
Sensor Shape Tag of an end-trigger event.
void setMoverSlopeLimit(float degrees)
Set maximum walkable slope in degrees, clamped to [0, 89.9].
Definition World3D.cpp:1928
int getIslandCount() const
Current solver-island count.
void setHitEventThreshold(float speed)
Minimum approach speed in m/s required for enabled Shape3D hit events.
Definition World3D.cpp:795
int getBeginContactShapeATag(int index) const
Shape Tag on stable side A of a begin-contact event.
int castBoxAll(float x, float y, float z, float width, float height, float depth, float qx, float qy, float qz, float qw, float dx, float dy, float dz, int maxHits)
Collects the nearest maxHits swept-oriented-box intersections.
Definition World3D.cpp:1826
int getStaticTreeHeight() const
Static broad-phase tree height.
int getContactPointOtherBodyId(int index) const
Other Body ID of a contact point.
int getEndTriggerSensorShapeId(int index) const
Sensor shape ID of an end-trigger event.
Mechanism3D * newCrankSlider(Body3D *frame, Body3D *crank, Body3D *rod, Body3D *slider, float crankAnchorX, float crankAnchorY, float crankAnchorZ, float axisX, float axisY, float axisZ, float crankPinX, float crankPinY, float crankPinZ, float sliderPinX, float sliderPinY, float sliderPinZ, float slideAxisX, float slideAxisY, float slideAxisZ, bool collideConnected=false)
Builds a planar crank-slider from frame, crank, connecting rod and slider bodies.
float getShapeCastResultNormalX(int index) const
Contact normal X of a Shape Cast result.
int getClosestBodyId() const
Stable body id from the latest closestPoint call, or -1.
Definition World3D.h:657
float getContactPointZ(int index) const
World-space contact point Z on the queried body.
int getBeginContactShapeBTag(int index) const
Shape Tag on stable side B of a begin-contact event.
float getExplosionResultDeltaAngularVelocityY(int index) const
Explosion-induced angular velocity delta Y.
float getExplosionResultDeltaVelocityY(int index) const
Explosion-induced linear velocity delta Y.
float getRayResultX(int index) const
World-space hit point X of a sorted ray result.
int getMemoryByteCount() const
Approximate Box3D world allocation in bytes.
int getEndTriggerVisitorShapeId(int index) const
Visitor shape ID of an end-trigger event.
int getQueryIgnoredShapeId() const
Stable Shape3D ID currently ignored by queries, or -1.
Definition World3D.h:953
int getEndTriggerVisitorShapeTag(int index) const
Visitor Shape Tag of an end-trigger event.
int getShapeCastBodyId() const
Stable body id from the last shape cast, or -1.
Definition World3D.h:680
float getShapeCastY() const
World-space contact point Y from the last shape cast.
Definition World3D.h:692
int getContactPointShapeId(int index) const
Queried-body Shape ID of a contact point.
float getExplosionResultDeltaAngularVelocityX(int index) const
Explosion-induced angular velocity delta X.
float getShapeCastResultX(int index) const
World-space contact point X of a Shape Cast result.
int queryBox(float x, float y, float z, float width, float height, float depth, float qx, float qy, float qz, float qw)
Query shapes overlapping an oriented box.
Definition World3D.cpp:1692
void setMaximumLinearSpeed(float speed)
Sets the finite positive world-wide linear velocity clamp in m/s.
Definition World3D.cpp:262
float getBoundsMinY() const
Minimum world-space Y covered by current broad-phase bounds.
Definition World3D.cpp:357
int getRayHitMaterialId() const
Surface material ID at the last ray intersection, or zero.
Definition World3D.h:521
Mechanism3D * newRatchet(Body3D *frame, Body3D *wheel, float anchorX, float anchorY, float anchorZ, float axisX, float axisY, float axisZ, int direction, float engagementTorque, bool collideConnected=false)
Builds a one-way ratchet around a revolute axis.
float getJointStressForceZ(int index) const
Constraint force Z of a stress event.
int getShapeCastResultTriangleIndex(int index) const
Mesh/height-field triangle index of a Shape Cast result, otherwise -1.
float getClosestNormalZ() const
Surface-to-target normal Z, or zero for an inside/on-surface target.
Definition World3D.h:673
Joint3D * newFilterJoint(Body3D *bodyA, Body3D *bodyB)
Disables collision between two specific bodies (filter joint).
int getExplosionResultCount() const
Number of bodies affected by the latest explosion.
Definition World3D.h:249
float getShapeCastResultZ(int index) const
World-space contact point Z of a Shape Cast result.
int getRayHitShapeTag() const
User tag of the shape from the last ray cast, or zero on no hit.
Definition World3D.h:519
Joint3D * newPrismaticJoint(Body3D *bodyA, Body3D *bodyB, float anchorX, float anchorY, float anchorZ, float axisX, float axisY, float axisZ, bool collideConnected=false)
Creates a slider whose permitted world-space translation follows axis.
Definition World3D.cpp:597
float getProfileSensorsMs() const
Latest sensor processing time in milliseconds.
Mechanism3D * newShaft(Body3D *support, Body3D *rotor, float anchorX, float anchorY, float anchorZ, float axisX, float axisY, float axisZ, bool collideConnected=false)
Builds a shaft (support↔rotor revolute) with optional drive motor helpers.
int getBodyCount() const
Current backend body count.
float getBoundsMinX() const
Minimum world-space X covered by current broad-phase bounds.
Definition World3D.cpp:354
int getAwakeContactCount() const
Contacts processed by the latest collide pass.
int getHitShapeBTag(int index) const
Shape Tag on side B of a hit.
float getClosestNormalY() const
Surface-to-target normal Y, or zero for an inside/on-surface target.
Definition World3D.h:671
Joint3D * newWheelJoint(Body3D *bodyA, Body3D *bodyB, float anchorX, float anchorY, float anchorZ, float suspensionAxisX, float suspensionAxisY, float suspensionAxisZ, float wheelAxisX, float wheelAxisY, float wheelAxisZ, bool collideConnected=false)
Creates a vehicle wheel joint with independent world suspension and spin axes.
Definition World3D.cpp:667
void setRestitutionThreshold(float speed)
Minimum impact speed that permits material restitution, in m/s.
Definition World3D.cpp:229
Joint3D * newDistanceJoint(Body3D *bodyA, Body3D *bodyB, float anchorAX, float anchorAY, float anchorAZ, float anchorBX, float anchorBY, float anchorBZ, float length, bool collideConnected=false)
Connects two world-space anchor points with a rigid distance constraint.
Definition World3D.cpp:532
float getContactRecycleDistance() const
Current contact-point persistence distance in meters.
Definition World3D.cpp:258
int getHitBodyAId(int index) const
Stable body ID on side A of a hit.
float getJointStressForceX(int index) const
Constraint force X of a stress event.
int queryAABB(float minX, float minY, float minZ, float maxX, float maxY, float maxZ)
Query shapes overlapping an AABB in meters (min/max corners). Returns match count; read ids with getQ...
Definition World3D.cpp:1502
float getContactPointNormalVelocity(int index) const
Pre-solve relative normal velocity; negative means approaching.
void updateFull(float dt, int subStepCount)
Steps with an explicit substep count.
Definition World3D.cpp:728
int castSphereAll(float x, float y, float z, float radius, float dx, float dy, float dz, int maxHits)
Collects the nearest maxHits swept-sphere intersections.
Definition World3D.cpp:1793
int getRayResultShapeTag(int index) const
Shape Tag of a sorted ray result.
void destroyBody(Body3D *body)
Destroys a body (null is ignored).
Definition World3D.cpp:997
int getShapeCastResultShapeTag(int index) const
Shape Tag of a sorted Shape Cast result.
void setContinuousCollisionEnabled(bool enabled)
Enables world-level continuous collision against static geometry.
Definition World3D.cpp:221
void setQueryIgnoredShapeId(int shapeId)
Ignores one stable Shape3D ID in subsequent spatial queries; -1 disables.
Definition World3D.cpp:986
float getShapeCastFraction() const
Translation fraction in [0,1] at the earliest hit.
Definition World3D.h:702
void clearQueryIgnores()
Clears Body and Shape query exclusions without changing layer filtering.
Definition World3D.cpp:992
float getBoundsMaxX() const
Maximum world-space X covered by current broad-phase bounds.
Definition World3D.cpp:363
int getBeginContactShapeBId(int index) const
Shape ID on stable side B of a begin-contact event.
int getEndTriggerSensorBodyId(int index) const
Sensor body ID of an end-trigger event.
int getEndTriggerVisitorBodyId(int index) const
Visitor body ID of an end-trigger event.
float getShapeCastNormalX() const
Contact normal X from the last shape cast.
Definition World3D.h:696
int getContactCount() const
Current backend contact count.
int getQueryIgnoredBodyId() const
Stable Body3D ID currently ignored by queries, or -1.
Definition World3D.h:951
int getContactPointCount() const
Number of points cached by queryBodyContacts.
Definition World3D.h:852
float getExplosionResultDeltaAngularVelocityZ(int index) const
Explosion-induced angular velocity delta Z.
float getRayResultNormalX(int index) const
Surface normal X of a sorted ray result.
float getShapeCastResultNormalY(int index) const
Contact normal Y of a Shape Cast result.
float getGravityZ() const
Definition World3D.cpp:790
float getProfileSolveMs() const
Latest constraint solver time in milliseconds.
void clearContactEvents()
Clears all contact and trigger buffers before the next step.
Definition World3D.cpp:1086
int getJointStressBodyBId(int index) const
Stable body B ID of a stress event.
int getEndContactShapeAId(int index) const
Shape ID on stable side A of an end-contact event.
void destroy()
Destroys the world and invalidates all wrappers.
Definition World3D.cpp:432
float getRayHitZ() const
Definition World3D.h:526
float getContactPointNormalX(int index) const
Contact normal X from queried body toward the other body.
float getShapeCastNormalY() const
Contact normal Y from the last shape cast.
Definition World3D.h:698
float getHitNormalY(int index) const
Hit normal Y, pointing from stable side A to B.
float getProfilePairsMs() const
Latest broad-phase pair generation time in milliseconds.
float getHitApproachSpeed(int index) const
Positive pre-solve approach speed in m/s.
bool hasShapeCastHit() const
Whether the last sphere, capsule, or box cast hit a body.
Definition World3D.h:678
void resetQueryFilter()
Restore the query filter to accept all lower-32-bit categories.
Definition World3D.cpp:975
void setShapePairCollisionEnabled(Shape3D *shapeA, Shape3D *shapeB, bool enabled)
Overrides collision for one live shape pair.
Definition World3D.cpp:835
int getRayHitBodyId() const
Definition World3D.h:515
bool isContactPointPersisted(int index) const
Whether this manifold point existed in the previous step.
Definition World3D.cpp:2339
float getClosestX() const
Closest surface point X.
Definition World3D.h:663
float getMoverNormalX() const
Representative blocking normal X from the last move.
Definition World3D.h:755
float getHitEventThreshold() const
Current significant-hit speed threshold in m/s.
Definition World3D.cpp:801
int getRecycledContactCount() const
Contact points recycled during the latest step.
int getShapeCastResultMaterialId(int index) const
Surface material ID at a sorted Shape Cast intersection.
int getEndContactBodyBId(int index) const
Body ID on stable side B of an end-contact event.
int getRayResultCount() const
Number of results cached by the latest rayCast or rayCastAll call.
Definition World3D.h:532
float getExplosionResultDeltaVelocityZ(int index) const
Explosion-induced linear velocity delta Z.
int rayCastAll(float x1, float y1, float z1, float x2, float y2, float z2, int maxHits)
Collects the nearest maxHits ray intersections, sorted by fraction then Shape ID.
Definition World3D.cpp:1405
Body3D * newBody(const std::string &bodyType, float x, float y, float z)
Creates a body in meter-space units.
Definition World3D.cpp:902
float getHitNormalZ(int index) const
Hit normal Z, pointing from stable side A to B.
int getBeginTriggerSensorShapeTag(int index) const
Sensor Shape Tag of a begin-trigger event.
float getBoundsMaxY() const
Maximum world-space Y covered by current broad-phase bounds.
Definition World3D.cpp:366
void setContactRecycleDistance(float distance)
Sets contact-point persistence distance in meters; zero disables recycling.
Definition World3D.cpp:252
float getRayResultNormalZ(int index) const
Surface normal Z of a sorted ray result.
float getRayHitFraction() const
Definition World3D.h:530
int getShapeCastResultBodyId(int index) const
Body ID of a sorted Shape Cast result.
int getHitShapeATag(int index) const
Shape Tag on side A of a hit.
bool moveCapsule(float ax, float ay, float az, float bx, float by, float bz, float radius, float dx, float dy, float dz)
Move a capsule with continuous collision and multi-plane sliding. Existing penetration is recovered b...
Definition World3D.cpp:1935
float getJointStressTorqueY(int index) const
Constraint torque Y of a stress event.
int getJointStressJointId(int index) const
Stable Joint3D ID of a stress event.
int getBeginContactBodyAId(int index) const
Body ID on stable side A of a begin-contact event.
int getBeginTriggerVisitorBodyId(int index) const
Visitor body ID of a begin-trigger event.
float getJointStressTorqueZ(int index) const
Constraint torque Z of a stress event.
int getMoverIterations() const
Number of outer solver passes used by the last move.
Definition World3D.h:763
float getRayResultY(int index) const
World-space hit point Y of a sorted ray result.
float getRayHitNormalY() const
Definition World3D.h:528
int getShapeCastResultCount() const
Number of results cached by the latest single or multi Shape Cast.
Definition World3D.h:704
int getMoverPlaneCount() const
Number of collision planes considered during the last move.
Definition World3D.h:761
float getJointStressTorqueX(int index) const
Constraint torque X of a stress event.
int getContactPointOtherShapeTag(int index) const
Other Shape Tag of a contact point.
int getShapeCount() const
Current backend shape count.
int getRayHitShapeId() const
Stable shape id from the last ray cast, or -1.
Definition World3D.h:517
float getHitPointY(int index) const
World-space impact point Y.
int getRayResultBodyId(int index) const
Body ID of a sorted ray result.
int getRayResultMaterialId(int index) const
Surface material ID at a sorted ray intersection.
float getContactPointNormalZ(int index) const
Contact normal Z from queried body toward the other body.
float getMoverGroundDot() const
Largest dot product between mover up and a contact normal.
Definition World3D.h:771
bool isMoverGrounded() const
True when the last move touched a walkable plane.
Definition World3D.h:769
float getRayResultZ(int index) const
World-space hit point Z of a sorted ray result.
Box2D world wrapper (2D physics) with pixel-space coordinates. Handles stepping, gravity,...
Definition World.h:41
void setMeter(float pixelsPerMeter)
Changes the pixels-per-meter conversion.
Definition World.cpp:414
float getRayHitX() const
Definition World.h:324
int getRayHitBodyId() const
Definition World.h:323
Joint2D * newDistanceJoint(Body *bodyA, Body *bodyB, float anchorAX, float anchorAY, float anchorBX, float anchorBY, float lengthPixels, bool collideConnected=false)
Connects two pixel-space anchors with a distance constraint.
Joint2D * newWheelJoint(Body *bodyA, Body *bodyB, float anchorX, float anchorY, float axisX, float axisY, bool collideConnected=false)
Creates a wheel joint with a pixel-space suspension axis.
void update(float dt)
Steps the simulation by dt seconds (5 velocity / 2 position iterations).
Definition World.cpp:354
int queryAABB(float x, float y, float w, float h)
Query fixtures overlapping an axis-aligned box in pixel space (x,y,w,h). Returns match count; read id...
Definition World.cpp:695
float getImpactNormalY(int index) const
Definition World.cpp:630
void destroyBody(Body *body)
Destroys a body (null is ignored).
Definition World.cpp:462
Joint2D * newWeldJoint(Body *bodyA, Body *bodyB, float anchorX, float anchorY, bool collideConnected=false)
Welds two bodies at a shared pixel-space anchor.
std::string getBeginContactFixtureATag(int index) const
Definition World.cpp:591
float getRayHitY() const
Definition World.h:325
std::string getEndContactFixtureATag(int index) const
Definition World.cpp:603
float getImpactPointX(int index) const
Definition World.cpp:621
void drawDebug(graphics::Graphics *gfx)
Optional: draw fixture AABBs via Graphics::drawSolidRect.
int getQueryBodyId(int index) const
Definition World.cpp:726
int getQueryCount() const
Definition World.h:336
int getEndContactBodyBId(int index) const
Definition World.cpp:600
int getBeginContactBodyBId(int index) const
Definition World.cpp:588
Joint2D * newPrismaticJoint(Body *bodyA, Body *bodyB, float anchorX, float anchorY, float axisX, float axisY, bool collideConnected=false)
Creates a prismatic slider along a pixel-space axis.
void destroy()
Destroys the underlying Box2D world and resets event buffers.
Definition World.cpp:259
void setGravity(float gx, float gy)
Sets the world gravity vector in pixels/s^2.
Definition World.cpp:399
int getEndContactBodyAId(int index) const
Definition World.cpp:597
int getImpactCount() const
Definition World.h:350
float getGravityX() const
Definition World.cpp:404
float getRayHitFraction() const
Fraction along the segment [0,1] of the closest hit.
Definition World.h:329
float getRayHitNormalY() const
Definition World.h:327
bool hasRayHit() const
Definition World.h:322
Joint2D * newRevoluteJoint(Body *bodyA, Body *bodyB, float anchorX, float anchorY, bool collideConnected=false)
Creates a revolute hinge at a shared pixel-space anchor.
float getImpactNormalX(int index) const
Definition World.cpp:627
float getImpactRelativeNormalSpeed(int index) const
Definition World.cpp:633
Body * newBody(const std::string &bodyType, float x, float y)
Creates a body in pixel-space units.
Definition World.cpp:431
Mechanism2D * newCrankSlider(Body *frame, Body *crank, Body *rod, Body *slider, float crankAnchorX, float crankAnchorY, float crankPinX, float crankPinY, float sliderPinX, float sliderPinY, float slideAxisX, float slideAxisY, bool collideConnected=false)
Builds a planar crank-slider from frame, crank, connecting rod and slider bodies.
int getBeginContactBodyAId(int index) const
Definition World.cpp:585
int getImpactBodyAId(int index) const
Definition World.cpp:609
int getBeginContactCount() const
Definition World.h:339
int getImpactBodyBId(int index) const
Definition World.cpp:612
float getRayHitNormalX() const
Definition World.h:326
Joint2D * newGearJoint(Joint2D *joint1, Joint2D *joint2, float ratio)
Creates a gear joint that couples two revolute or prismatic joints.
Mechanism2D * newRatchet(Body *frame, Body *wheel, float anchorX, float anchorY, int direction, float engagementTorque, bool collideConnected=false)
Builds a one-way ratchet around a revolute hinge.
int getEndContactCount() const
Definition World.h:344
float getImpactNormalImpulse(int index) const
Definition World.cpp:636
std::string getEndContactFixtureBTag(int index) const
Definition World.cpp:606
int rayCast(float x1, float y1, float x2, float y2)
Closest raycast in pixel space from (x1,y1) to (x2,y2). Returns hit body id, or -1....
Definition World.cpp:650
float getImpactTangentImpulse(int index) const
Definition World.cpp:639
float getGravityY() const
Definition World.cpp:409
std::string getBeginContactFixtureBTag(int index) const
Definition World.cpp:594
void updateFull(float dt, int velocityIterations, int positionIterations)
Steps with explicit iteration counts.
Definition World.cpp:356
void clearContactEvents()
Clears collected begin/end contact and impact event buffers.
Definition World.cpp:643
std::string getImpactFixtureATag(int index) const
Definition World.cpp:615
std::string getImpactFixtureBTag(int index) const
Definition World.cpp:618
float getMeter() const
Definition World.h:161
Joint2D * newMotorJoint(Body *bodyA, Body *bodyB, bool collideConnected=false)
Creates a motor joint that drives relative pose between bodies.
float getImpactPointY(int index) const
Definition World.cpp:624
Mechanism2D * newShaft(Body *support, Body *rotor, float anchorX, float anchorY, bool collideConnected=false)
Builds a shaft (support↔rotor revolute) with optional drive motor helpers.
Optional physics backend for vehicle mobility and body attach.
Definition Climbing.h:36
Result< void > beginTerrainLoadGravity(TerrainLoadGravityState *state, Body3D *body, bool terrainFound)
Begin monitoring a body when a containing terrain scene exists.
Result< bool > advanceTerrainLoadGravity(TerrainLoadGravityState *state, Body3D *body, bool terrainLoaded, float deltaSeconds, float activationDelay)
Advance terrain-load waiting and restore gravity after the configured delay.
void registerPhysicsCapabilities()
Registers physics capabilities.
const EditorValue * field(const EditorValue &value, const char *name)
std::unordered_map< std::string, SkillDefinition > & table()
Definition Skill.cpp:65
ssq::Table projectResult(HSQUIRRELVM vm, Result< void > &&result)
Consume and project a void native Result using the common schema.