载入中...
搜索中...
未找到
Physics.cpp
浏览该文件的文档.
1#include "physics/Physics.h"
2#include "common/SdfField3D.h"
3#include "physics/Body.h"
4#include "physics/Body3D.h"
7#include "physics/Fixture.h"
8#include "physics/Fluid2D.h"
9#include "physics/Joint2D.h"
10#include "physics/Joint3D.h"
11#include "physics/Mechanism2D.h"
12#include "physics/Mechanism3D.h"
14#include "physics/Shape3D.h"
16#include "physics/World.h"
17#include "physics/World3D.h"
25
26#include "common/Exception.h"
29
30#include <simplesquirrel/simplesquirrel.hpp>
31
32#include <algorithm>
33#include <vector>
34
35namespace eve::physics {
36
38
40
41void Physics::setMeter(float pixelsPerMeter) {
42 if (pixelsPerMeter <= 0.f) throw Exception("Physics.setMeter: pixelsPerMeter must be > 0");
43 meter_ = pixelsPerMeter;
44}
45
46float Physics::getMeter() const { return meter_; }
47
48DistanceField3D* Physics::newDistanceField3D(int width, int height, int depth, float cellSize, float originX,
49 float originY, float originZ, float outsideDistance) {
50 return new DistanceField3D(width, height, depth, cellSize, originX, originY, originZ, outsideDistance);
51}
52
53SoftBody3D* Physics::newSoftBody3D(int cols, int rows, int layers, float spacing, float originX, float originY,
54 float originZ) {
55 auto created = SoftBody3D::create(cols, rows, layers, spacing, originX, originY, originZ);
56 if (!created) throw Exception("%s", created.status().describe().c_str());
57 return std::move(created).takeValue().release();
58}
59
61
63
64void Physics::expose(ssq::Table& table) {
65 PhysicsBake::expose(table);
66 PhysicsBakeRecording::expose(table);
70 auto cls = table.addClass(name, Physics::create, false);
71 expose(cls);
72 cls.addFunc("bake", [](Physics*) { return PhysicsBake::create(); });
73 cls.addFunc("bakeRecording", [](Physics*) { return PhysicsBakeRecording::create(); });
74 auto terrainLoadState = table.addClass<TerrainLoadGravityState>("TerrainLoadGravityState");
75 terrainLoadState.addFunc("isMonitoring", &TerrainLoadGravityState::isMonitoring);
76 terrainLoadState.addFunc("isActivationScheduled", &TerrainLoadGravityState::isActivationScheduled);
77 terrainLoadState.addFunc("isCompleted", &TerrainLoadGravityState::isCompleted);
78 terrainLoadState.addFunc("getDelayElapsed", &TerrainLoadGravityState::getDelayElapsed);
79 table.addFunc("beginTerrainLoadGravity",
80 [vm = table.getHandle()](TerrainLoadGravityState* state, Body3D* body, bool terrainFound) {
81 return eve::script::projectResult(vm, beginTerrainLoadGravity(state, body, terrainFound));
82 });
83 table.addFunc("advanceTerrainLoadGravity", [vm = table.getHandle()](TerrainLoadGravityState* state, Body3D* body,
84 bool terrainLoaded, float dt, float delay) {
85 return eve::script::projectResult(vm, advanceTerrainLoadGravity(state, body, terrainLoaded, dt, delay),
86 [](bool activated) { return eve::Value(activated); });
87 });
88
89 auto world = table.addClass<World>("World", std::function<World*()>([]() -> World* { return nullptr; }), true);
90 world.addFunc("update", &World::update);
91 world.addFunc("updateFull", &World::updateFull);
92 world.addFunc("setGravity", &World::setGravity);
93 world.addFunc("getGravityX", &World::getGravityX);
94 world.addFunc("getGravityY", &World::getGravityY);
95 world.addFunc("setMeter", &World::setMeter);
96 world.addFunc("getMeter", &World::getMeter);
97 world.addFunc("newBody", &World::newBody);
98 world.addFunc("newDistanceJoint", &World::newDistanceJoint);
99 world.addFunc("newRevoluteJoint", &World::newRevoluteJoint);
100 world.addFunc("newPrismaticJoint", &World::newPrismaticJoint);
101 world.addFunc("newWeldJoint", &World::newWeldJoint);
102 world.addFunc("newWheelJoint", &World::newWheelJoint);
103 world.addFunc("newMotorJoint", &World::newMotorJoint);
104 world.addFunc("newGearJoint", &World::newGearJoint);
105 world.addFunc("newShaft", &World::newShaft);
106 world.addFunc("newRatchet", &World::newRatchet);
107 world.addFunc("newCrankSlider", &World::newCrankSlider);
108 world.addFunc("destroyBody", &World::destroyBody);
109 world.addFunc("destroy", &World::destroy);
110 world.addFunc("drawDebug", &World::drawDebug);
111 world.addFunc("rayCast", &World::rayCast);
112 world.addFunc("hasRayHit", &World::hasRayHit);
113 world.addFunc("getRayHitBodyId", &World::getRayHitBodyId);
114 world.addFunc("getRayHitX", &World::getRayHitX);
115 world.addFunc("getRayHitY", &World::getRayHitY);
116 world.addFunc("getRayHitNormalX", &World::getRayHitNormalX);
117 world.addFunc("getRayHitNormalY", &World::getRayHitNormalY);
118 world.addFunc("getRayHitFraction", &World::getRayHitFraction);
119 world.addFunc("queryAABB", &World::queryAABB);
120 world.addFunc("getQueryCount", &World::getQueryCount);
121 world.addFunc("getQueryBodyId", &World::getQueryBodyId);
122 world.addFunc("getBeginContactCount", &World::getBeginContactCount);
123 world.addFunc("getBeginContactBodyAId", &World::getBeginContactBodyAId);
124 world.addFunc("getBeginContactBodyBId", &World::getBeginContactBodyBId);
125 world.addFunc("getBeginContactFixtureATag", &World::getBeginContactFixtureATag);
126 world.addFunc("getBeginContactFixtureBTag", &World::getBeginContactFixtureBTag);
127 world.addFunc("getEndContactCount", &World::getEndContactCount);
128 world.addFunc("getEndContactBodyAId", &World::getEndContactBodyAId);
129 world.addFunc("getEndContactBodyBId", &World::getEndContactBodyBId);
130 world.addFunc("getEndContactFixtureATag", &World::getEndContactFixtureATag);
131 world.addFunc("getEndContactFixtureBTag", &World::getEndContactFixtureBTag);
132 world.addFunc("getBeginTriggerCount", &World::getBeginTriggerCount);
133 world.addFunc("getBeginTriggerSensorBodyId", &World::getBeginTriggerSensorBodyId);
134 world.addFunc("getBeginTriggerVisitorBodyId", &World::getBeginTriggerVisitorBodyId);
135 world.addFunc("getBeginTriggerSensorFixtureTag", &World::getBeginTriggerSensorFixtureTag);
136 world.addFunc("getBeginTriggerVisitorFixtureTag", &World::getBeginTriggerVisitorFixtureTag);
137 world.addFunc("getEndTriggerCount", &World::getEndTriggerCount);
138 world.addFunc("getEndTriggerSensorBodyId", &World::getEndTriggerSensorBodyId);
139 world.addFunc("getEndTriggerVisitorBodyId", &World::getEndTriggerVisitorBodyId);
140 world.addFunc("getEndTriggerSensorFixtureTag", &World::getEndTriggerSensorFixtureTag);
141 world.addFunc("getEndTriggerVisitorFixtureTag", &World::getEndTriggerVisitorFixtureTag);
142 world.addFunc("getImpactCount", &World::getImpactCount);
143 world.addFunc("getImpactBodyAId", &World::getImpactBodyAId);
144 world.addFunc("getImpactBodyBId", &World::getImpactBodyBId);
145 world.addFunc("getImpactFixtureATag", &World::getImpactFixtureATag);
146 world.addFunc("getImpactFixtureBTag", &World::getImpactFixtureBTag);
147 world.addFunc("getImpactPointX", &World::getImpactPointX);
148 world.addFunc("getImpactPointY", &World::getImpactPointY);
149 world.addFunc("getImpactNormalX", &World::getImpactNormalX);
150 world.addFunc("getImpactNormalY", &World::getImpactNormalY);
151 world.addFunc("getImpactRelativeNormalSpeed", &World::getImpactRelativeNormalSpeed);
152 world.addFunc("getImpactNormalImpulse", &World::getImpactNormalImpulse);
153 world.addFunc("getImpactTangentImpulse", &World::getImpactTangentImpulse);
154 world.addFunc("clearContactEvents", &World::clearContactEvents);
155
156 auto world3 =
157 table.addClass<World3D>("World3D", std::function<World3D*()>([]() -> World3D* { return nullptr; }), true);
158 world3.addFunc("queryToken", &World3D::queryToken);
159 world3.addFunc("applySweepContactImpulse",
160 [](World3D* self, ssq::Object event, float ix, float iy, float iz, float px, float py, float pz) {
161 return projectSweepContactImpulse(self, event, {ix, iy, iz}, {px, py, pz});
162 });
163 world3.addFunc("update", &World3D::update);
164 world3.addFunc("updateFull", &World3D::updateFull);
165 world3.addFunc("setGravity", &World3D::setGravity);
166 world3.addFunc("getGravityX", &World3D::getGravityX);
167 world3.addFunc("getGravityY", &World3D::getGravityY);
168 world3.addFunc("getGravityZ", &World3D::getGravityZ);
169 world3.addFunc("setContinuousCollisionEnabled", &World3D::setContinuousCollisionEnabled);
170 world3.addFunc("isContinuousCollisionEnabled", &World3D::isContinuousCollisionEnabled);
171 world3.addFunc("setRestitutionThreshold", &World3D::setRestitutionThreshold);
172 world3.addFunc("getRestitutionThreshold", &World3D::getRestitutionThreshold);
173 world3.addFunc("setHitEventThreshold", &World3D::setHitEventThreshold);
174 world3.addFunc("getHitEventThreshold", &World3D::getHitEventThreshold);
175 world3.addFunc("setBodyPairCollisionEnabled", &World3D::setBodyPairCollisionEnabled);
176 world3.addFunc("isBodyPairCollisionEnabled", &World3D::isBodyPairCollisionEnabled);
177 world3.addFunc("setShapePairCollisionEnabled", &World3D::setShapePairCollisionEnabled);
178 world3.addFunc("isShapePairCollisionEnabled", &World3D::isShapePairCollisionEnabled);
179 world3.addFunc("setContactTuning", &World3D::setContactTuning);
180 world3.addFunc("getContactHertz", &World3D::getContactHertz);
181 world3.addFunc("getContactDampingRatio", &World3D::getContactDampingRatio);
182 world3.addFunc("getContactPushOutSpeed", &World3D::getContactPushOutSpeed);
183 world3.addFunc("setContactRecycleDistance", &World3D::setContactRecycleDistance);
184 world3.addFunc("getContactRecycleDistance", &World3D::getContactRecycleDistance);
185 world3.addFunc("setMaximumLinearSpeed", &World3D::setMaximumLinearSpeed);
186 world3.addFunc("getMaximumLinearSpeed", &World3D::getMaximumLinearSpeed);
187 world3.addFunc("setWarmStartingEnabled", &World3D::setWarmStartingEnabled);
188 world3.addFunc("isWarmStartingEnabled", &World3D::isWarmStartingEnabled);
189 world3.addFunc("explode", &World3D::explode);
190 world3.addFunc("getExplosionResultCount", &World3D::getExplosionResultCount);
191 world3.addFunc("getExplosionResultBodyId", &World3D::getExplosionResultBodyId);
192 world3.addFunc("getExplosionResultDeltaVelocityX", &World3D::getExplosionResultDeltaVelocityX);
193 world3.addFunc("getExplosionResultDeltaVelocityY", &World3D::getExplosionResultDeltaVelocityY);
194 world3.addFunc("getExplosionResultDeltaVelocityZ", &World3D::getExplosionResultDeltaVelocityZ);
195 world3.addFunc("getExplosionResultDeltaAngularVelocityX", &World3D::getExplosionResultDeltaAngularVelocityX);
196 world3.addFunc("getExplosionResultDeltaAngularVelocityY", &World3D::getExplosionResultDeltaAngularVelocityY);
197 world3.addFunc("getExplosionResultDeltaAngularVelocityZ", &World3D::getExplosionResultDeltaAngularVelocityZ);
198 world3.addFunc("getBoundsMinX", &World3D::getBoundsMinX);
199 world3.addFunc("getBoundsMinY", &World3D::getBoundsMinY);
200 world3.addFunc("getBoundsMinZ", &World3D::getBoundsMinZ);
201 world3.addFunc("getBoundsMaxX", &World3D::getBoundsMaxX);
202 world3.addFunc("getBoundsMaxY", &World3D::getBoundsMaxY);
203 world3.addFunc("getBoundsMaxZ", &World3D::getBoundsMaxZ);
204 world3.addFunc("getBodyCount", &World3D::getBodyCount);
205 world3.addFunc("getShapeCount", &World3D::getShapeCount);
206 world3.addFunc("getContactCount", &World3D::getContactCount);
207 world3.addFunc("getJointCount", &World3D::getJointCount);
208 world3.addFunc("getIslandCount", &World3D::getIslandCount);
209 world3.addFunc("getAwakeBodyCount", &World3D::getAwakeBodyCount);
210 world3.addFunc("getAwakeContactCount", &World3D::getAwakeContactCount);
211 world3.addFunc("getRecycledContactCount", &World3D::getRecycledContactCount);
212 world3.addFunc("getStaticTreeHeight", &World3D::getStaticTreeHeight);
213 world3.addFunc("getDynamicTreeHeight", &World3D::getDynamicTreeHeight);
214 world3.addFunc("getMemoryByteCount", &World3D::getMemoryByteCount);
215 world3.addFunc("getProfileStepMs", &World3D::getProfileStepMs);
216 world3.addFunc("getProfilePairsMs", &World3D::getProfilePairsMs);
217 world3.addFunc("getProfileCollideMs", &World3D::getProfileCollideMs);
218 world3.addFunc("getProfileSolveMs", &World3D::getProfileSolveMs);
219 world3.addFunc("getProfileBulletsMs", &World3D::getProfileBulletsMs);
220 world3.addFunc("getProfileSensorsMs", &World3D::getProfileSensorsMs);
221 world3.addFunc("newBody", &World3D::newBody);
222 world3.addFunc("newDistanceJoint", &World3D::newDistanceJoint);
223 world3.addFunc("newRevoluteJoint", &World3D::newRevoluteJoint);
224 world3.addFunc("newPrismaticJoint", &World3D::newPrismaticJoint);
225 world3.addFunc("newSphericalJoint", &World3D::newSphericalJoint);
226 world3.addFunc("newWheelJoint", &World3D::newWheelJoint);
227 world3.addFunc("newWeldJoint", &World3D::newWeldJoint);
228 world3.addFunc("newMotorJoint", &World3D::newMotorJoint);
229 world3.addFunc("newParallelJoint", &World3D::newParallelJoint);
230 world3.addFunc("newFilterJoint", &World3D::newFilterJoint);
231 world3.addFunc("newShaft", &World3D::newShaft);
232 world3.addFunc("newRatchet", &World3D::newRatchet);
233 world3.addFunc("newCrankSlider", &World3D::newCrankSlider);
234 world3.addFunc("destroyBody", &World3D::destroyBody);
235 world3.addFunc("destroy", &World3D::destroy);
236 world3.addFunc("rayCast", &World3D::rayCast);
237 world3.addFunc("rayCastAll", &World3D::rayCastAll);
238 world3.addFunc("hasRayHit", &World3D::hasRayHit);
239 world3.addFunc("getRayHitBodyId", &World3D::getRayHitBodyId);
240 world3.addFunc("getRayHitShapeId", &World3D::getRayHitShapeId);
241 world3.addFunc("getRayHitShapeTag", &World3D::getRayHitShapeTag);
242 world3.addFunc("getRayHitMaterialId", &World3D::getRayHitMaterialId);
243 world3.addFunc("getRayHitTriangleIndex", &World3D::getRayHitTriangleIndex);
244 world3.addFunc("getRayHitX", &World3D::getRayHitX);
245 world3.addFunc("getRayHitY", &World3D::getRayHitY);
246 world3.addFunc("getRayHitZ", &World3D::getRayHitZ);
247 world3.addFunc("getRayHitNormalX", &World3D::getRayHitNormalX);
248 world3.addFunc("getRayHitNormalY", &World3D::getRayHitNormalY);
249 world3.addFunc("getRayHitNormalZ", &World3D::getRayHitNormalZ);
250 world3.addFunc("getRayHitFraction", &World3D::getRayHitFraction);
251 world3.addFunc("getRayResultCount", &World3D::getRayResultCount);
252 world3.addFunc("getRayResultBodyId", &World3D::getRayResultBodyId);
253 world3.addFunc("getRayResultShapeId", &World3D::getRayResultShapeId);
254 world3.addFunc("getRayResultShapeTag", &World3D::getRayResultShapeTag);
255 world3.addFunc("getRayResultMaterialId", &World3D::getRayResultMaterialId);
256 world3.addFunc("getRayResultTriangleIndex", &World3D::getRayResultTriangleIndex);
257 world3.addFunc("getRayResultX", &World3D::getRayResultX);
258 world3.addFunc("getRayResultY", &World3D::getRayResultY);
259 world3.addFunc("getRayResultZ", &World3D::getRayResultZ);
260 world3.addFunc("getRayResultNormalX", &World3D::getRayResultNormalX);
261 world3.addFunc("getRayResultNormalY", &World3D::getRayResultNormalY);
262 world3.addFunc("getRayResultNormalZ", &World3D::getRayResultNormalZ);
263 world3.addFunc("getRayResultFraction", &World3D::getRayResultFraction);
264 world3.addFunc("queryAABB", &World3D::queryAABB);
265 world3.addFunc("querySphere", &World3D::querySphere);
266 world3.addFunc("queryCapsule", &World3D::queryCapsule);
267 world3.addFunc("queryBox", &World3D::queryBox);
268 world3.addFunc("castSphere", &World3D::castSphere);
269 world3.addFunc("castSphereAll", &World3D::castSphereAll);
270 world3.addFunc("castCapsule", &World3D::castCapsule);
271 world3.addFunc("castCapsuleAll", &World3D::castCapsuleAll);
272 world3.addFunc("castBox", &World3D::castBox);
273 world3.addFunc("castBoxAll", &World3D::castBoxAll);
274 world3.addFunc("closestPoint", &World3D::closestPoint);
275 world3.addFunc("hasClosestPoint", &World3D::hasClosestPoint);
276 world3.addFunc("getClosestBodyId", &World3D::getClosestBodyId);
277 world3.addFunc("getClosestShapeId", &World3D::getClosestShapeId);
278 world3.addFunc("getClosestShapeTag", &World3D::getClosestShapeTag);
279 world3.addFunc("getClosestX", &World3D::getClosestX);
280 world3.addFunc("getClosestY", &World3D::getClosestY);
281 world3.addFunc("getClosestZ", &World3D::getClosestZ);
282 world3.addFunc("getClosestNormalX", &World3D::getClosestNormalX);
283 world3.addFunc("getClosestNormalY", &World3D::getClosestNormalY);
284 world3.addFunc("getClosestNormalZ", &World3D::getClosestNormalZ);
285 world3.addFunc("getClosestDistance", &World3D::getClosestDistance);
286 world3.addFunc("hasShapeCastHit", &World3D::hasShapeCastHit);
287 world3.addFunc("getShapeCastBodyId", &World3D::getShapeCastBodyId);
288 world3.addFunc("getShapeCastShapeId", &World3D::getShapeCastShapeId);
289 world3.addFunc("getShapeCastShapeTag", &World3D::getShapeCastShapeTag);
290 world3.addFunc("getShapeCastMaterialId", &World3D::getShapeCastMaterialId);
291 world3.addFunc("getShapeCastTriangleIndex", &World3D::getShapeCastTriangleIndex);
292 world3.addFunc("getShapeCastX", &World3D::getShapeCastX);
293 world3.addFunc("getShapeCastY", &World3D::getShapeCastY);
294 world3.addFunc("getShapeCastZ", &World3D::getShapeCastZ);
295 world3.addFunc("getShapeCastNormalX", &World3D::getShapeCastNormalX);
296 world3.addFunc("getShapeCastNormalY", &World3D::getShapeCastNormalY);
297 world3.addFunc("getShapeCastNormalZ", &World3D::getShapeCastNormalZ);
298 world3.addFunc("getShapeCastFraction", &World3D::getShapeCastFraction);
299 world3.addFunc("getShapeCastResultCount", &World3D::getShapeCastResultCount);
300 world3.addFunc("getShapeCastResultBodyId", &World3D::getShapeCastResultBodyId);
301 world3.addFunc("getShapeCastResultShapeId", &World3D::getShapeCastResultShapeId);
302 world3.addFunc("getShapeCastResultShapeTag", &World3D::getShapeCastResultShapeTag);
303 world3.addFunc("getShapeCastResultMaterialId", &World3D::getShapeCastResultMaterialId);
304 world3.addFunc("getShapeCastResultTriangleIndex", &World3D::getShapeCastResultTriangleIndex);
305 world3.addFunc("getShapeCastResultX", &World3D::getShapeCastResultX);
306 world3.addFunc("getShapeCastResultY", &World3D::getShapeCastResultY);
307 world3.addFunc("getShapeCastResultZ", &World3D::getShapeCastResultZ);
308 world3.addFunc("getShapeCastResultNormalX", &World3D::getShapeCastResultNormalX);
309 world3.addFunc("getShapeCastResultNormalY", &World3D::getShapeCastResultNormalY);
310 world3.addFunc("getShapeCastResultNormalZ", &World3D::getShapeCastResultNormalZ);
311 world3.addFunc("getShapeCastResultFraction", &World3D::getShapeCastResultFraction);
312 world3.addFunc("moveCapsule", &World3D::moveCapsule);
313 world3.addFunc("getMoverDeltaX", &World3D::getMoverDeltaX);
314 world3.addFunc("getMoverDeltaY", &World3D::getMoverDeltaY);
315 world3.addFunc("getMoverDeltaZ", &World3D::getMoverDeltaZ);
316 world3.addFunc("getMoverNormalX", &World3D::getMoverNormalX);
317 world3.addFunc("getMoverNormalY", &World3D::getMoverNormalY);
318 world3.addFunc("getMoverNormalZ", &World3D::getMoverNormalZ);
319 world3.addFunc("getMoverPlaneCount", &World3D::getMoverPlaneCount);
320 world3.addFunc("getMoverIterations", &World3D::getMoverIterations);
321 world3.addFunc("setMoverUp", &World3D::setMoverUp);
322 world3.addFunc("setMoverSlopeLimit", &World3D::setMoverSlopeLimit);
323 world3.addFunc("isMoverGrounded", &World3D::isMoverGrounded);
324 world3.addFunc("getMoverGroundDot", &World3D::getMoverGroundDot);
325 world3.addFunc("getQueryCount", &World3D::getQueryCount);
326 world3.addFunc("getQueryBodyId", &World3D::getQueryBodyId);
327 world3.addFunc("getQueryShapeCount", &World3D::getQueryShapeCount);
328 world3.addFunc("getQueryShapeId", &World3D::getQueryShapeId);
329 world3.addFunc("getQueryShapeTag", &World3D::getQueryShapeTag);
330 world3.addFunc("getBeginContactCount", &World3D::getBeginContactCount);
331 world3.addFunc("getBeginContactBodyAId", &World3D::getBeginContactBodyAId);
332 world3.addFunc("getBeginContactBodyBId", &World3D::getBeginContactBodyBId);
333 world3.addFunc("getBeginContactShapeAId", &World3D::getBeginContactShapeAId);
334 world3.addFunc("getBeginContactShapeBId", &World3D::getBeginContactShapeBId);
335 world3.addFunc("getBeginContactShapeATag", &World3D::getBeginContactShapeATag);
336 world3.addFunc("getBeginContactShapeBTag", &World3D::getBeginContactShapeBTag);
337 world3.addFunc("getEndContactCount", &World3D::getEndContactCount);
338 world3.addFunc("getEndContactBodyAId", &World3D::getEndContactBodyAId);
339 world3.addFunc("getEndContactBodyBId", &World3D::getEndContactBodyBId);
340 world3.addFunc("getEndContactShapeAId", &World3D::getEndContactShapeAId);
341 world3.addFunc("getEndContactShapeBId", &World3D::getEndContactShapeBId);
342 world3.addFunc("getEndContactShapeATag", &World3D::getEndContactShapeATag);
343 world3.addFunc("getEndContactShapeBTag", &World3D::getEndContactShapeBTag);
344 world3.addFunc("getBeginTriggerCount", &World3D::getBeginTriggerCount);
345 world3.addFunc("getBeginTriggerSensorBodyId", &World3D::getBeginTriggerSensorBodyId);
346 world3.addFunc("getBeginTriggerVisitorBodyId", &World3D::getBeginTriggerVisitorBodyId);
347 world3.addFunc("getBeginTriggerSensorShapeId", &World3D::getBeginTriggerSensorShapeId);
348 world3.addFunc("getBeginTriggerVisitorShapeId", &World3D::getBeginTriggerVisitorShapeId);
349 world3.addFunc("getBeginTriggerSensorShapeTag", &World3D::getBeginTriggerSensorShapeTag);
350 world3.addFunc("getBeginTriggerVisitorShapeTag", &World3D::getBeginTriggerVisitorShapeTag);
351 world3.addFunc("getEndTriggerCount", &World3D::getEndTriggerCount);
352 world3.addFunc("getEndTriggerSensorBodyId", &World3D::getEndTriggerSensorBodyId);
353 world3.addFunc("getEndTriggerVisitorBodyId", &World3D::getEndTriggerVisitorBodyId);
354 world3.addFunc("getEndTriggerSensorShapeId", &World3D::getEndTriggerSensorShapeId);
355 world3.addFunc("getEndTriggerVisitorShapeId", &World3D::getEndTriggerVisitorShapeId);
356 world3.addFunc("getEndTriggerSensorShapeTag", &World3D::getEndTriggerSensorShapeTag);
357 world3.addFunc("getEndTriggerVisitorShapeTag", &World3D::getEndTriggerVisitorShapeTag);
358 world3.addFunc("clearContactEvents", &World3D::clearContactEvents);
359 world3.addFunc("queryBodyContacts", &World3D::queryBodyContacts);
360 world3.addFunc("getContactPointCount", &World3D::getContactPointCount);
361 world3.addFunc("getContactPointShapeId", &World3D::getContactPointShapeId);
362 world3.addFunc("getContactPointShapeTag", &World3D::getContactPointShapeTag);
363 world3.addFunc("getContactPointOtherBodyId", &World3D::getContactPointOtherBodyId);
364 world3.addFunc("getContactPointOtherShapeId", &World3D::getContactPointOtherShapeId);
365 world3.addFunc("getContactPointOtherShapeTag", &World3D::getContactPointOtherShapeTag);
366 world3.addFunc("getContactPointX", &World3D::getContactPointX);
367 world3.addFunc("getContactPointY", &World3D::getContactPointY);
368 world3.addFunc("getContactPointZ", &World3D::getContactPointZ);
369 world3.addFunc("getContactPointNormalX", &World3D::getContactPointNormalX);
370 world3.addFunc("getContactPointNormalY", &World3D::getContactPointNormalY);
371 world3.addFunc("getContactPointNormalZ", &World3D::getContactPointNormalZ);
372 world3.addFunc("getContactPointSeparation", &World3D::getContactPointSeparation);
373 world3.addFunc("getContactPointNormalImpulse", &World3D::getContactPointNormalImpulse);
374 world3.addFunc("getContactPointTotalNormalImpulse", &World3D::getContactPointTotalNormalImpulse);
375 world3.addFunc("getContactPointNormalVelocity", &World3D::getContactPointNormalVelocity);
376 world3.addFunc("isContactPointPersisted", &World3D::isContactPointPersisted);
377 world3.addFunc("getHitCount", &World3D::getHitCount);
378 world3.addFunc("getHitBodyAId", &World3D::getHitBodyAId);
379 world3.addFunc("getHitBodyBId", &World3D::getHitBodyBId);
380 world3.addFunc("getHitShapeAId", &World3D::getHitShapeAId);
381 world3.addFunc("getHitShapeBId", &World3D::getHitShapeBId);
382 world3.addFunc("getHitShapeATag", &World3D::getHitShapeATag);
383 world3.addFunc("getHitShapeBTag", &World3D::getHitShapeBTag);
384 world3.addFunc("getHitPointX", &World3D::getHitPointX);
385 world3.addFunc("getHitPointY", &World3D::getHitPointY);
386 world3.addFunc("getHitPointZ", &World3D::getHitPointZ);
387 world3.addFunc("getHitNormalX", &World3D::getHitNormalX);
388 world3.addFunc("getHitNormalY", &World3D::getHitNormalY);
389 world3.addFunc("getHitNormalZ", &World3D::getHitNormalZ);
390 world3.addFunc("getHitApproachSpeed", &World3D::getHitApproachSpeed);
391 world3.addFunc("getHitNormalImpulse", &World3D::getHitNormalImpulse);
392 world3.addFunc("getJointStressCount", &World3D::getJointStressCount);
393 world3.addFunc("getJointStressJointId", &World3D::getJointStressJointId);
394 world3.addFunc("getJointStressBodyAId", &World3D::getJointStressBodyAId);
395 world3.addFunc("getJointStressBodyBId", &World3D::getJointStressBodyBId);
396 world3.addFunc("getJointStressKind", &World3D::getJointStressKind);
397 world3.addFunc("getJointStressForceX", &World3D::getJointStressForceX);
398 world3.addFunc("getJointStressForceY", &World3D::getJointStressForceY);
399 world3.addFunc("getJointStressForceZ", &World3D::getJointStressForceZ);
400 world3.addFunc("getJointStressTorqueX", &World3D::getJointStressTorqueX);
401 world3.addFunc("getJointStressTorqueY", &World3D::getJointStressTorqueY);
402 world3.addFunc("getJointStressTorqueZ", &World3D::getJointStressTorqueZ);
403 world3.addFunc("setQueryFilter", &World3D::setQueryFilter);
404 world3.addFunc("resetQueryFilter", &World3D::resetQueryFilter);
405 world3.addFunc("getQueryCategoryBits", &World3D::getQueryCategoryBits);
406 world3.addFunc("getQueryMaskBits", &World3D::getQueryMaskBits);
407 world3.addFunc("setQueryIgnoredBodyId", &World3D::setQueryIgnoredBodyId);
408 world3.addFunc("setQueryIgnoredShapeId", &World3D::setQueryIgnoredShapeId);
409 world3.addFunc("getQueryIgnoredBodyId", &World3D::getQueryIgnoredBodyId);
410 world3.addFunc("getQueryIgnoredShapeId", &World3D::getQueryIgnoredShapeId);
411 world3.addFunc("clearQueryIgnores", &World3D::clearQueryIgnores);
412
413 auto sdf = table.addClass<DistanceField3D>(
414 "DistanceField3D", std::function<DistanceField3D*()>([]() -> DistanceField3D* { return nullptr; }), true);
415 sdf.addFunc("setDistances", [](DistanceField3D* field, ssq::Array values) {
416 std::vector<float> distances;
417 distances.reserve(values.size());
418 const size_t count = values.size();
419 for (size_t i = 0; i < count; ++i) distances.push_back(values.get<float>(i));
420 field->setDistances(distances);
421 });
422 sdf.addFunc("setDistanceRegion",
423 [](DistanceField3D* field, int x, int y, int z, int width, int height, int depth, ssq::Array values) {
424 std::vector<float> distances;
425 const size_t count = values.size();
426 distances.reserve(count);
427 for (size_t i = 0; i < count; ++i) 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>("Body", std::function<Body*()>([]() -> Body* { return nullptr; }), true);
488 body.addFunc("getId", &Body::getId);
489 body.addFunc("setPosition", &Body::setPosition);
490 body.addFunc("getX", &Body::getX);
491 body.addFunc("getY", &Body::getY);
492 body.addFunc("setAngle", &Body::setAngle);
493 body.addFunc("getAngle", &Body::getAngle);
494 body.addFunc("setLinearVelocity", &Body::setLinearVelocity);
495 body.addFunc("getLinearVelocityX", &Body::getLinearVelocityX);
496 body.addFunc("getLinearVelocityY", &Body::getLinearVelocityY);
497 body.addFunc("getLinearSpeed", &Body::getLinearSpeed);
498 body.addFunc("getMass", &Body::getMass);
499 body.addFunc("getWorldCenterX", &Body::getWorldCenterX);
500 body.addFunc("getWorldCenterY", &Body::getWorldCenterY);
501 body.addFunc("setAngularVelocity", &Body::setAngularVelocity);
502 body.addFunc("getAngularVelocity", &Body::getAngularVelocity);
503 body.addFunc("applyForce", &Body::applyForce);
504 body.addFunc("applyForceAt", &Body::applyForceAt);
505 body.addFunc("applyLinearImpulse", &Body::applyLinearImpulse);
506 body.addFunc("applyAngularImpulse", &Body::applyAngularImpulse);
507 body.addFunc("setType", &Body::setType);
508 body.addFunc("getType", &Body::getType);
509 body.addFunc("setFixedRotation", &Body::setFixedRotation);
510 body.addFunc("isFixedRotation", &Body::isFixedRotation);
511 body.addFunc("setActive", &Body::setActive);
512 body.addFunc("isActive", &Body::isActive);
513 body.addFunc("setBullet", &Body::setBullet);
514 body.addFunc("isBullet", &Body::isBullet);
515 body.addFunc("setAwake", &Body::setAwake);
516 body.addFunc("isAwake", &Body::isAwake);
517 body.addFunc("newRectangleFixture", &Body::newRectangleFixture);
518 body.addFunc("newRectangleFixtureAt", &Body::newRectangleFixtureAt);
519 body.addFunc("newCircleFixture", &Body::newCircleFixture);
520 body.addFunc("destroy", &Body::destroy);
521
522
523 auto mechanism2 = table.addClass<Mechanism2D>(
524 "Mechanism2D", std::function<Mechanism2D*()>([]() -> Mechanism2D* { return nullptr; }), true);
525 mechanism2.addFunc("getId", &Mechanism2D::getId);
526 mechanism2.addFunc("getKind", &Mechanism2D::getKind);
527 mechanism2.addFunc("isValid", &Mechanism2D::isValid);
528 mechanism2.addFunc("getDriveJoint", &Mechanism2D::getDriveJoint);
529 mechanism2.addFunc("getCrankPinJoint", &Mechanism2D::getCrankPinJoint);
530 mechanism2.addFunc("getSliderPinJoint", &Mechanism2D::getSliderPinJoint);
531 mechanism2.addFunc("getSliderJoint", &Mechanism2D::getSliderJoint);
532 mechanism2.addFunc("getDriveAngle", &Mechanism2D::getDriveAngle);
533 mechanism2.addFunc("getSliderTranslation", &Mechanism2D::getSliderTranslation);
534 mechanism2.addFunc("getSpinSpeed", &Mechanism2D::getSpinSpeed);
535 mechanism2.addFunc("setDrive", &Mechanism2D::setDrive);
536 mechanism2.addFunc("clearDrive", &Mechanism2D::clearDrive);
537 mechanism2.addFunc("isDriveEnabled", &Mechanism2D::isDriveEnabled);
538 mechanism2.addFunc("setRatchetDirection", &Mechanism2D::setRatchetDirection);
539 mechanism2.addFunc("getRatchetDirection", &Mechanism2D::getRatchetDirection);
540 mechanism2.addFunc("setRatchetEngagementTorque", &Mechanism2D::setRatchetEngagementTorque);
541 mechanism2.addFunc("getRatchetEngagementTorque", &Mechanism2D::getRatchetEngagementTorque);
542 mechanism2.addFunc("destroy", &Mechanism2D::destroy);
543
544 auto body3 = table.addClass<Body3D>("Body3D", std::function<Body3D*()>([]() -> Body3D* { return nullptr; }), true);
545 body3.addFunc("getId", &Body3D::getId);
546 body3.addFunc("setPosition", &Body3D::setPosition);
547 body3.addFunc("getX", &Body3D::getX);
548 body3.addFunc("getY", &Body3D::getY);
549 body3.addFunc("getZ", &Body3D::getZ);
550 body3.addFunc("setRotation", &Body3D::setRotation);
551 body3.addFunc("getRotX", &Body3D::getRotX);
552 body3.addFunc("getRotY", &Body3D::getRotY);
553 body3.addFunc("getRotZ", &Body3D::getRotZ);
554 body3.addFunc("getRotW", &Body3D::getRotW);
555 body3.addFunc("setLinearVelocity", &Body3D::setLinearVelocity);
556 body3.addFunc("getLinearVelocityX", &Body3D::getLinearVelocityX);
557 body3.addFunc("getLinearVelocityY", &Body3D::getLinearVelocityY);
558 body3.addFunc("getLinearVelocityZ", &Body3D::getLinearVelocityZ);
559 body3.addFunc("getMass", &Body3D::getMass);
560 body3.addFunc("setAngularVelocity", &Body3D::setAngularVelocity);
561 body3.addFunc("getAngularVelocityX", &Body3D::getAngularVelocityX);
562 body3.addFunc("getAngularVelocityY", &Body3D::getAngularVelocityY);
563 body3.addFunc("getAngularVelocityZ", &Body3D::getAngularVelocityZ);
564 body3.addFunc("localToWorldPoint", &Body3D::localToWorldPoint);
565 body3.addFunc("worldToLocalPoint", &Body3D::worldToLocalPoint);
566 body3.addFunc("localToWorldVector", &Body3D::localToWorldVector);
567 body3.addFunc("worldToLocalVector", &Body3D::worldToLocalVector);
568 body3.addFunc("getLocalPointVelocity", &Body3D::getLocalPointVelocity);
569 body3.addFunc("getWorldPointVelocity", &Body3D::getWorldPointVelocity);
570 body3.addFunc("applyForce", &Body3D::applyForce);
571 body3.addFunc("applyForceAt", &Body3D::applyForceAt);
572 body3.addFunc("applyTorque", &Body3D::applyTorque);
573 body3.addFunc("applyLinearImpulse", &Body3D::applyLinearImpulse);
574 body3.addFunc("applyLinearImpulseAt", &Body3D::applyLinearImpulseAt);
575 body3.addFunc("applyAngularImpulse", &Body3D::applyAngularImpulse);
576 body3.addFunc("applyLocalForce", &Body3D::applyLocalForce);
577 body3.addFunc("applyLocalForceToCenter", &Body3D::applyLocalForceToCenter);
578 body3.addFunc("applyLocalTorque", &Body3D::applyLocalTorque);
579 body3.addFunc("applyLocalLinearImpulse", &Body3D::applyLocalLinearImpulse);
580 body3.addFunc("applyLocalLinearImpulseToCenter", &Body3D::applyLocalLinearImpulseToCenter);
581 body3.addFunc("applyLocalAngularImpulse", &Body3D::applyLocalAngularImpulse);
582 body3.addFunc("setTargetTransform", &Body3D::setTargetTransform);
583 body3.addFunc("setLinearDamping", &Body3D::setLinearDamping);
584 body3.addFunc("getLinearDamping", &Body3D::getLinearDamping);
585 body3.addFunc("setAngularDamping", &Body3D::setAngularDamping);
586 body3.addFunc("getAngularDamping", &Body3D::getAngularDamping);
587 body3.addFunc("setGravityScale", &Body3D::setGravityScale);
588 body3.addFunc("getGravityScale", &Body3D::getGravityScale);
589 body3.addFunc("setSleepEnabled", &Body3D::setSleepEnabled);
590 body3.addFunc("isSleepEnabled", &Body3D::isSleepEnabled);
591 body3.addFunc("setSleepThreshold", &Body3D::setSleepThreshold);
592 body3.addFunc("getSleepThreshold", &Body3D::getSleepThreshold);
593 body3.addFunc("setMotionLocks", &Body3D::setMotionLocks);
594 body3.addFunc("isLinearXLocked", &Body3D::isLinearXLocked);
595 body3.addFunc("isLinearYLocked", &Body3D::isLinearYLocked);
596 body3.addFunc("isLinearZLocked", &Body3D::isLinearZLocked);
597 body3.addFunc("isAngularXLocked", &Body3D::isAngularXLocked);
598 body3.addFunc("isAngularYLocked", &Body3D::isAngularYLocked);
599 body3.addFunc("isAngularZLocked", &Body3D::isAngularZLocked);
600 body3.addFunc("getMass", &Body3D::getMass);
601 body3.addFunc("setMassProperties", &Body3D::setMassProperties);
602 body3.addFunc("resetMassProperties", &Body3D::resetMassProperties);
603 body3.addFunc("getInertiaXX", &Body3D::getInertiaXX);
604 body3.addFunc("getInertiaYY", &Body3D::getInertiaYY);
605 body3.addFunc("getInertiaZZ", &Body3D::getInertiaZZ);
606 body3.addFunc("getInertiaXY", &Body3D::getInertiaXY);
607 body3.addFunc("getInertiaXZ", &Body3D::getInertiaXZ);
608 body3.addFunc("getInertiaYZ", &Body3D::getInertiaYZ);
609 body3.addFunc("getLocalCenterX", &Body3D::getLocalCenterX);
610 body3.addFunc("getLocalCenterY", &Body3D::getLocalCenterY);
611 body3.addFunc("getLocalCenterZ", &Body3D::getLocalCenterZ);
612 body3.addFunc("getWorldCenterX", &Body3D::getWorldCenterX);
613 body3.addFunc("getWorldCenterY", &Body3D::getWorldCenterY);
614 body3.addFunc("getWorldCenterZ", &Body3D::getWorldCenterZ);
615 body3.addFunc("setType", &Body3D::setType);
616 body3.addFunc("getType", &Body3D::getType);
617 body3.addFunc("setFixedRotation", &Body3D::setFixedRotation);
618 body3.addFunc("isFixedRotation", &Body3D::isFixedRotation);
619 body3.addFunc("setActive", &Body3D::setActive);
620 body3.addFunc("isActive", &Body3D::isActive);
621 body3.addFunc("setBullet", &Body3D::setBullet);
622 body3.addFunc("isBullet", &Body3D::isBullet);
623 body3.addFunc("setAwake", &Body3D::setAwake);
624 body3.addFunc("isAwake", &Body3D::isAwake);
625 body3.addFunc("newBoxShape", &Body3D::newBoxShape);
626 body3.addFunc("newSphereShape", &Body3D::newSphereShape);
627 body3.addFunc("newCapsuleShape", &Body3D::newCapsuleShape);
628 body3.addFunc("newConvexHullShape", [](Body3D* body, ssq::Array values, int maxVertices) {
629 std::vector<float> vertices;
630 vertices.reserve(values.size());
631 for (size_t i = 0; i < values.size(); ++i) vertices.push_back(values.get<float>(i));
632 return body->newConvexHullShape(vertices, maxVertices);
633 });
634 body3.addFunc("newTriangleMeshShape", [](Body3D* body, ssq::Array vertexValues, ssq::Array indexValues) {
635 std::vector<float> vertices;
636 std::vector<int32_t> indices;
637 vertices.reserve(vertexValues.size());
638 indices.reserve(indexValues.size());
639 for (size_t i = 0; i < vertexValues.size(); ++i) vertices.push_back(vertexValues.get<float>(i));
640 for (size_t i = 0; i < indexValues.size(); ++i) indices.push_back(indexValues.get<int32_t>(i));
641 return body->newTriangleMeshShape(vertices, indices);
642 });
643 body3.addFunc("newTriangleMeshShapeFull",
644 [](Body3D* body, ssq::Array vertexValues, ssq::Array indexValues, bool weldVertices,
645 float weldTolerance, bool identifyEdges, bool useMedianSplit) {
646 std::vector<float> vertices;
647 std::vector<int32_t> indices;
648 vertices.reserve(vertexValues.size());
649 indices.reserve(indexValues.size());
650 for (size_t i = 0; i < vertexValues.size(); ++i) vertices.push_back(vertexValues.get<float>(i));
651 for (size_t i = 0; i < indexValues.size(); ++i) indices.push_back(indexValues.get<int32_t>(i));
652 return body->newTriangleMeshShape(vertices, indices, weldVertices, weldTolerance, identifyEdges,
653 useMedianSplit);
654 });
655 body3.addFunc("newHeightFieldShape", [](Body3D* body, int countX, int countZ, float cellSizeX, float cellSizeZ,
656 ssq::Array values) {
657 std::vector<float> heights;
658 heights.reserve(values.size());
659 for (size_t i = 0; i < values.size(); ++i) heights.push_back(values.get<float>(i));
660 if (heights.empty()) throw eve::Exception("Body3D.newHeightFieldShape: heights is empty");
661 const auto range = std::minmax_element(heights.begin(), heights.end());
662 return body->newHeightFieldShape(countX, countZ, cellSizeX, cellSizeZ, heights, *range.first, *range.second);
663 });
664 body3.addFunc("newHeightFieldShapeFull",
665 [](Body3D* body, int countX, int countZ, float cellSizeX, float cellSizeZ, ssq::Array values,
666 float globalMin, float globalMax, bool clockwiseWinding) {
667 std::vector<float> heights;
668 heights.reserve(values.size());
669 for (size_t i = 0; i < values.size(); ++i) heights.push_back(values.get<float>(i));
670 return body->newHeightFieldShape(countX, countZ, cellSizeX, cellSizeZ, heights, globalMin,
671 globalMax, clockwiseWinding);
672 });
673 body3.addFunc("destroy", &Body3D::destroy);
674
675 auto joint3 =
676 table.addClass<Joint3D>("Joint3D", std::function<Joint3D*()>([]() -> Joint3D* { return nullptr; }), true);
677 joint3.addFunc("getId", &Joint3D::getId);
678 joint3.addFunc("getKind", &Joint3D::getKind);
679 joint3.addFunc("getBodyAId", &Joint3D::getBodyAId);
680 joint3.addFunc("getBodyBId", &Joint3D::getBodyBId);
681 joint3.addFunc("setCollideConnected", &Joint3D::setCollideConnected);
682 joint3.addFunc("getCollideConnected", &Joint3D::getCollideConnected);
683 joint3.addFunc("setForceThreshold", &Joint3D::setForceThreshold);
684 joint3.addFunc("getForceThreshold", &Joint3D::getForceThreshold);
685 joint3.addFunc("setTorqueThreshold", &Joint3D::setTorqueThreshold);
686 joint3.addFunc("getTorqueThreshold", &Joint3D::getTorqueThreshold);
687 joint3.addFunc("getConstraintForceX", &Joint3D::getConstraintForceX);
688 joint3.addFunc("getConstraintForceY", &Joint3D::getConstraintForceY);
689 joint3.addFunc("getConstraintForceZ", &Joint3D::getConstraintForceZ);
690 joint3.addFunc("getConstraintTorqueX", &Joint3D::getConstraintTorqueX);
691 joint3.addFunc("getConstraintTorqueY", &Joint3D::getConstraintTorqueY);
692 joint3.addFunc("getConstraintTorqueZ", &Joint3D::getConstraintTorqueZ);
693 joint3.addFunc("getLinearSeparation", &Joint3D::getLinearSeparation);
694 joint3.addFunc("getAngularSeparation", &Joint3D::getAngularSeparation);
695 joint3.addFunc("setDistanceLength", &Joint3D::setDistanceLength);
696 joint3.addFunc("getDistanceLength", &Joint3D::getDistanceLength);
697 joint3.addFunc("getDistanceCurrentLength", &Joint3D::getDistanceCurrentLength);
698 joint3.addFunc("setDistanceSpring", &Joint3D::setDistanceSpring);
699 joint3.addFunc("setDistanceLimits", &Joint3D::setDistanceLimits);
700 joint3.addFunc("setDistanceMotor", &Joint3D::setDistanceMotor);
701 joint3.addFunc("setRevoluteSpring", &Joint3D::setRevoluteSpring);
702 joint3.addFunc("setRevoluteLimits", &Joint3D::setRevoluteLimits);
703 joint3.addFunc("setRevoluteMotor", &Joint3D::setRevoluteMotor);
704 joint3.addFunc("getRevoluteAngle", &Joint3D::getRevoluteAngle);
705 joint3.addFunc("getRevoluteMotorTorque", &Joint3D::getRevoluteMotorTorque);
706 joint3.addFunc("setPrismaticSpring", &Joint3D::setPrismaticSpring);
707 joint3.addFunc("setPrismaticLimits", &Joint3D::setPrismaticLimits);
708 joint3.addFunc("setPrismaticMotor", &Joint3D::setPrismaticMotor);
709 joint3.addFunc("getPrismaticTranslation", &Joint3D::getPrismaticTranslation);
710 joint3.addFunc("getPrismaticSpeed", &Joint3D::getPrismaticSpeed);
711 joint3.addFunc("getPrismaticMotorForce", &Joint3D::getPrismaticMotorForce);
712 joint3.addFunc("setSphericalConeLimit", &Joint3D::setSphericalConeLimit);
713 joint3.addFunc("setSphericalTwistLimits", &Joint3D::setSphericalTwistLimits);
714 joint3.addFunc("setSphericalMotor", &Joint3D::setSphericalMotor);
715 joint3.addFunc("getSphericalConeAngle", &Joint3D::getSphericalConeAngle);
716 joint3.addFunc("getSphericalTwistAngle", &Joint3D::getSphericalTwistAngle);
717 joint3.addFunc("setWheelSuspension", &Joint3D::setWheelSuspension);
718 joint3.addFunc("setWheelSuspensionLimits", &Joint3D::setWheelSuspensionLimits);
719 joint3.addFunc("setWheelSpinMotor", &Joint3D::setWheelSpinMotor);
720 joint3.addFunc("setWheelSteering", &Joint3D::setWheelSteering);
721 joint3.addFunc("setWheelSteeringLimits", &Joint3D::setWheelSteeringLimits);
722 joint3.addFunc("getWheelSpinSpeed", &Joint3D::getWheelSpinSpeed);
723 joint3.addFunc("getWheelSpinTorque", &Joint3D::getWheelSpinTorque);
724 joint3.addFunc("getWheelSteeringAngle", &Joint3D::getWheelSteeringAngle);
725 joint3.addFunc("getWheelSteeringTorque", &Joint3D::getWheelSteeringTorque);
726 joint3.addFunc("setWeldLinearSpring", &Joint3D::setWeldLinearSpring);
727 joint3.addFunc("setWeldAngularSpring", &Joint3D::setWeldAngularSpring);
728 joint3.addFunc("getWeldLinearHertz", &Joint3D::getWeldLinearHertz);
729 joint3.addFunc("getWeldLinearDampingRatio", &Joint3D::getWeldLinearDampingRatio);
730 joint3.addFunc("getWeldAngularHertz", &Joint3D::getWeldAngularHertz);
731 joint3.addFunc("getWeldAngularDampingRatio", &Joint3D::getWeldAngularDampingRatio);
732 joint3.addFunc("setMotorLinearVelocity", &Joint3D::setMotorLinearVelocity);
733 joint3.addFunc("setMotorAngularVelocity", &Joint3D::setMotorAngularVelocity);
734 joint3.addFunc("setMotorVelocityLimits", &Joint3D::setMotorVelocityLimits);
735 joint3.addFunc("setMotorLinearSpring", &Joint3D::setMotorLinearSpring);
736 joint3.addFunc("setMotorAngularSpring", &Joint3D::setMotorAngularSpring);
737 joint3.addFunc("getMotorLinearVelocityX", &Joint3D::getMotorLinearVelocityX);
738 joint3.addFunc("getMotorLinearVelocityY", &Joint3D::getMotorLinearVelocityY);
739 joint3.addFunc("getMotorLinearVelocityZ", &Joint3D::getMotorLinearVelocityZ);
740 joint3.addFunc("getMotorAngularVelocityX", &Joint3D::getMotorAngularVelocityX);
741 joint3.addFunc("getMotorAngularVelocityY", &Joint3D::getMotorAngularVelocityY);
742 joint3.addFunc("getMotorAngularVelocityZ", &Joint3D::getMotorAngularVelocityZ);
743 joint3.addFunc("setParallelSpring", &Joint3D::setParallelSpring);
744 joint3.addFunc("getParallelHertz", &Joint3D::getParallelHertz);
745 joint3.addFunc("getParallelDampingRatio", &Joint3D::getParallelDampingRatio);
746 joint3.addFunc("getParallelMaxTorque", &Joint3D::getParallelMaxTorque);
747 joint3.addFunc("destroy", &Joint3D::destroy);
748
749 auto mechanism3 = table.addClass<Mechanism3D>(
750 "Mechanism3D", std::function<Mechanism3D*()>([]() -> Mechanism3D* { return nullptr; }), true);
751 mechanism3.addFunc("getId", &Mechanism3D::getId);
752 mechanism3.addFunc("getKind", &Mechanism3D::getKind);
753 mechanism3.addFunc("isValid", &Mechanism3D::isValid);
754 mechanism3.addFunc("getDriveJoint", &Mechanism3D::getDriveJoint);
755 mechanism3.addFunc("getCrankPinJoint", &Mechanism3D::getCrankPinJoint);
756 mechanism3.addFunc("getSliderPinJoint", &Mechanism3D::getSliderPinJoint);
757 mechanism3.addFunc("getSliderJoint", &Mechanism3D::getSliderJoint);
758 mechanism3.addFunc("getDriveAngle", &Mechanism3D::getDriveAngle);
759 mechanism3.addFunc("getSliderTranslation", &Mechanism3D::getSliderTranslation);
760 mechanism3.addFunc("getSpinSpeed", &Mechanism3D::getSpinSpeed);
761 mechanism3.addFunc("setDrive", &Mechanism3D::setDrive);
762 mechanism3.addFunc("clearDrive", &Mechanism3D::clearDrive);
763 mechanism3.addFunc("isDriveEnabled", &Mechanism3D::isDriveEnabled);
764 mechanism3.addFunc("setRatchetDirection", &Mechanism3D::setRatchetDirection);
765 mechanism3.addFunc("getRatchetDirection", &Mechanism3D::getRatchetDirection);
766 mechanism3.addFunc("setRatchetEngagementTorque", &Mechanism3D::setRatchetEngagementTorque);
767 mechanism3.addFunc("getRatchetEngagementTorque", &Mechanism3D::getRatchetEngagementTorque);
768 mechanism3.addFunc("destroy", &Mechanism3D::destroy);
769
770 auto fixture =
771 table.addClass<Fixture>("Fixture", std::function<Fixture*()>([]() -> Fixture* { return nullptr; }), true);
772 fixture.addFunc("setSensor", &Fixture::setSensor);
773 fixture.addFunc("isSensor", &Fixture::isSensor);
774 fixture.addFunc("setFriction", &Fixture::setFriction);
775 fixture.addFunc("getFriction", &Fixture::getFriction);
776 fixture.addFunc("setRestitution", &Fixture::setRestitution);
777 fixture.addFunc("getRestitution", &Fixture::getRestitution);
778 fixture.addFunc("setDensity", &Fixture::setDensity);
779 fixture.addFunc("getDensity", &Fixture::getDensity);
780 fixture.addFunc("setTag", &Fixture::setTag);
781 fixture.addFunc("getTag", &Fixture::getTag);
782 fixture.addFunc("setCategoryBits", &Fixture::setCategoryBits);
783 fixture.addFunc("getCategoryBits", &Fixture::getCategoryBits);
784 fixture.addFunc("setMaskBits", &Fixture::setMaskBits);
785 fixture.addFunc("getMaskBits", &Fixture::getMaskBits);
786 fixture.addFunc("setGroupIndex", &Fixture::setGroupIndex);
787 fixture.addFunc("getGroupIndex", &Fixture::getGroupIndex);
788 fixture.addFunc("getBodyId", &Fixture::getBodyId);
789 fixture.addFunc("getBody", &Fixture::getBody);
790 fixture.addFunc("testPoint", &Fixture::testPoint);
791 fixture.addFunc("destroy", &Fixture::destroy);
792
793 auto shape3 =
794 table.addClass<Shape3D>("Shape3D", std::function<Shape3D*()>([]() -> Shape3D* { return nullptr; }), true);
795 shape3.addFunc("getId", &Shape3D::getId);
796 shape3.addFunc("setTag", &Shape3D::setTag);
797 shape3.addFunc("getTag", &Shape3D::getTag);
798 shape3.addFunc("setHitEventsEnabled", &Shape3D::setHitEventsEnabled);
799 shape3.addFunc("areHitEventsEnabled", &Shape3D::areHitEventsEnabled);
800 shape3.addFunc("setOneWay", &Shape3D::setOneWay);
801 shape3.addFunc("disableOneWay", &Shape3D::disableOneWay);
802 shape3.addFunc("isOneWay", &Shape3D::isOneWay);
803 shape3.addFunc("getKind", &Shape3D::getKind);
804 shape3.addFunc("setBoxSize", &Shape3D::setBoxSize);
805 shape3.addFunc("setSphereRadius", &Shape3D::setSphereRadius);
806 shape3.addFunc("setCapsuleSize", &Shape3D::setCapsuleSize);
807 shape3.addFunc("setConvexHullVertices", [](Shape3D* shape, ssq::Array values, int maxVertices) {
808 std::vector<float> vertices;
809 vertices.reserve(values.size());
810 for (size_t i = 0; i < values.size(); ++i) vertices.push_back(values.get<float>(i));
811 shape->setConvexHullVertices(vertices, maxVertices);
812 });
813 shape3.addFunc("getConvexHullPointCount", &Shape3D::getConvexHullPointCount);
814 shape3.addFunc("getConvexHullMaxVertices", &Shape3D::getConvexHullMaxVertices);
815 shape3.addFunc("setTriangleMeshData", [](Shape3D* shape, ssq::Array vertexValues, ssq::Array indexValues) {
816 std::vector<float> vertices;
817 std::vector<int32_t> indices;
818 vertices.reserve(vertexValues.size());
819 indices.reserve(indexValues.size());
820 for (size_t i = 0; i < vertexValues.size(); ++i) vertices.push_back(vertexValues.get<float>(i));
821 for (size_t i = 0; i < indexValues.size(); ++i) indices.push_back(indexValues.get<int32_t>(i));
822 shape->setTriangleMeshData(vertices, indices);
823 });
824 shape3.addFunc(
825 "setTriangleMeshDataFull", [](Shape3D* shape, ssq::Array vertexValues, ssq::Array indexValues,
826 bool weldVertices, float weldTolerance, bool identifyEdges, bool useMedianSplit) {
827 std::vector<float> vertices;
828 std::vector<int32_t> indices;
829 vertices.reserve(vertexValues.size());
830 indices.reserve(indexValues.size());
831 for (size_t i = 0; i < vertexValues.size(); ++i) vertices.push_back(vertexValues.get<float>(i));
832 for (size_t i = 0; i < indexValues.size(); ++i) indices.push_back(indexValues.get<int32_t>(i));
833 shape->setTriangleMeshData(vertices, indices, weldVertices, weldTolerance, identifyEdges, useMedianSplit);
834 });
835 shape3.addFunc("getTriangleMeshVertexCount", &Shape3D::getTriangleMeshVertexCount);
836 shape3.addFunc("getTriangleMeshTriangleCount", &Shape3D::getTriangleMeshTriangleCount);
837 shape3.addFunc("setTriangleMeshMaterialIndices", [](Shape3D* shape, ssq::Array values) {
838 std::vector<int32_t> indices;
839 indices.reserve(values.size());
840 for (size_t i = 0; i < values.size(); ++i) indices.push_back(values.get<int32_t>(i));
841 shape->setTriangleMeshMaterialIndices(indices);
842 });
843 shape3.addFunc("getTriangleMeshMaterialIndex", &Shape3D::getTriangleMeshMaterialIndex);
844 shape3.addFunc("getTriangleMeshMaterialCount", &Shape3D::getTriangleMeshMaterialCount);
845 shape3.addFunc("setTriangleMeshMaterial", &Shape3D::setTriangleMeshMaterial);
846 shape3.addFunc("getTriangleMeshMaterialFriction", &Shape3D::getTriangleMeshMaterialFriction);
847 shape3.addFunc("getTriangleMeshMaterialRestitution", &Shape3D::getTriangleMeshMaterialRestitution);
848 shape3.addFunc("getTriangleMeshMaterialRollingResistance", &Shape3D::getTriangleMeshMaterialRollingResistance);
849 shape3.addFunc("getTriangleMeshMaterialId", &Shape3D::getTriangleMeshMaterialId);
850 shape3.addFunc("setHeightFieldHeights", [](Shape3D* shape, ssq::Array values) {
851 std::vector<float> heights;
852 heights.reserve(values.size());
853 for (size_t i = 0; i < values.size(); ++i) heights.push_back(values.get<float>(i));
854 shape->setHeightFieldHeights(heights);
855 });
856 shape3.addFunc("setHeightFieldRegion", [](Shape3D* shape, int x, int z, int width, int depth, ssq::Array values) {
857 std::vector<float> heights;
858 heights.reserve(values.size());
859 for (size_t i = 0; i < values.size(); ++i) heights.push_back(values.get<float>(i));
860 shape->setHeightFieldRegion(x, z, width, depth, heights);
861 });
862 shape3.addFunc("getHeightFieldHeight", &Shape3D::getHeightFieldHeight);
863 shape3.addFunc("getHeightFieldCountX", &Shape3D::getHeightFieldCountX);
864 shape3.addFunc("getHeightFieldCountZ", &Shape3D::getHeightFieldCountZ);
865 shape3.addFunc("getHeightFieldCellSizeX", &Shape3D::getHeightFieldCellSizeX);
866 shape3.addFunc("getHeightFieldCellSizeZ", &Shape3D::getHeightFieldCellSizeZ);
867 shape3.addFunc("getHeightFieldGlobalMin", &Shape3D::getHeightFieldGlobalMin);
868 shape3.addFunc("getHeightFieldGlobalMax", &Shape3D::getHeightFieldGlobalMax);
869 shape3.addFunc("getBoxWidth", &Shape3D::getBoxWidth);
870 shape3.addFunc("getBoxHeight", &Shape3D::getBoxHeight);
871 shape3.addFunc("getBoxDepth", &Shape3D::getBoxDepth);
872 shape3.addFunc("getRadius", &Shape3D::getRadius);
873 shape3.addFunc("getCapsuleHeight", &Shape3D::getCapsuleHeight);
874 shape3.addFunc("setLocalTransform", &Shape3D::setLocalTransform);
875 shape3.addFunc("setLocalPosition", &Shape3D::setLocalPosition);
876 shape3.addFunc("setLocalRotation", &Shape3D::setLocalRotation);
877 shape3.addFunc("getLocalX", &Shape3D::getLocalX);
878 shape3.addFunc("getLocalY", &Shape3D::getLocalY);
879 shape3.addFunc("getLocalZ", &Shape3D::getLocalZ);
880 shape3.addFunc("getLocalRotX", &Shape3D::getLocalRotX);
881 shape3.addFunc("getLocalRotY", &Shape3D::getLocalRotY);
882 shape3.addFunc("getLocalRotZ", &Shape3D::getLocalRotZ);
883 shape3.addFunc("getLocalRotW", &Shape3D::getLocalRotW);
884 shape3.addFunc("setSensor", &Shape3D::setSensor);
885 shape3.addFunc("isSensor", &Shape3D::isSensor);
886 shape3.addFunc("setFriction", &Shape3D::setFriction);
887 shape3.addFunc("getFriction", &Shape3D::getFriction);
888 shape3.addFunc("setRestitution", &Shape3D::setRestitution);
889 shape3.addFunc("getRestitution", &Shape3D::getRestitution);
890 shape3.addFunc("setRollingResistance", &Shape3D::setRollingResistance);
891 shape3.addFunc("getRollingResistance", &Shape3D::getRollingResistance);
892 shape3.addFunc("setTangentVelocity", &Shape3D::setTangentVelocity);
893 shape3.addFunc("getTangentVelocityX", &Shape3D::getTangentVelocityX);
894 shape3.addFunc("getTangentVelocityY", &Shape3D::getTangentVelocityY);
895 shape3.addFunc("getTangentVelocityZ", &Shape3D::getTangentVelocityZ);
896 shape3.addFunc("setMaterialId", &Shape3D::setMaterialId);
897 shape3.addFunc("getMaterialId", &Shape3D::getMaterialId);
898 shape3.addFunc("setExplosionScale", &Shape3D::setExplosionScale);
899 shape3.addFunc("getExplosionScale", &Shape3D::getExplosionScale);
900 shape3.addFunc("setFrictionCombineMode", &Shape3D::setFrictionCombineMode);
901 shape3.addFunc("getFrictionCombineMode", &Shape3D::getFrictionCombineMode);
902 shape3.addFunc("setRestitutionCombineMode", &Shape3D::setRestitutionCombineMode);
903 shape3.addFunc("getRestitutionCombineMode", &Shape3D::getRestitutionCombineMode);
904 shape3.addFunc("setDensity", &Shape3D::setDensity);
905 shape3.addFunc("getDensity", &Shape3D::getDensity);
906 shape3.addFunc("setCategoryBits",
907 [](Shape3D* shape, int64_t bits) { shape->setCategoryBits(static_cast<uint64_t>(bits)); });
908 shape3.addFunc("getCategoryBits", [](Shape3D* shape) { return static_cast<int64_t>(shape->getCategoryBits()); });
909 shape3.addFunc("setMaskBits",
910 [](Shape3D* shape, int64_t bits) { shape->setMaskBits(static_cast<uint64_t>(bits)); });
911 shape3.addFunc("getMaskBits", [](Shape3D* shape) { return static_cast<int64_t>(shape->getMaskBits()); });
912 shape3.addFunc("setGroupIndex", &Shape3D::setGroupIndex);
913 shape3.addFunc("getGroupIndex", &Shape3D::getGroupIndex);
914 shape3.addFunc("getBody", [](Shape3D* shape) { return shape->getBody(); });
915 shape3.addFunc("testPoint", &Shape3D::testPoint);
916 shape3.addFunc("destroy", &Shape3D::destroy);
917
918 auto soft3 = table.addClass<SoftBody3D>(
919 "SoftBody3D", std::function<SoftBody3D*()>([]() -> SoftBody3D* { return nullptr; }), true);
920 soft3.addFunc("update", &SoftBody3D::update);
921 soft3.addFunc("setGravity", &SoftBody3D::setGravity);
922 soft3.addFunc("getGravityX", &SoftBody3D::getGravityX);
923 soft3.addFunc("getGravityY", &SoftBody3D::getGravityY);
924 soft3.addFunc("getGravityZ", &SoftBody3D::getGravityZ);
925 soft3.addFunc("setDeformationResistance", &SoftBody3D::setDeformationResistance);
926 soft3.addFunc("getDeformationResistance", &SoftBody3D::getDeformationResistance);
927 soft3.addFunc("setIterations", &SoftBody3D::setIterations);
928 soft3.addFunc("getIterations", &SoftBody3D::getIterations);
929 soft3.addFunc("setDamping", &SoftBody3D::setDamping);
930 soft3.addFunc("getDamping", &SoftBody3D::getDamping);
931 soft3.addFunc("setParticleRadius", &SoftBody3D::setParticleRadius);
932 soft3.addFunc("getParticleRadius", &SoftBody3D::getParticleRadius);
933 soft3.addFunc("setParticleMass", &SoftBody3D::setParticleMass);
934 soft3.addFunc("getParticleMass", &SoftBody3D::getParticleMass);
935 soft3.addFunc("setPlasticity", &SoftBody3D::setPlasticity);
936 soft3.addFunc("getPlasticYield", &SoftBody3D::getPlasticYield);
937 soft3.addFunc("getPlasticCreep", &SoftBody3D::getPlasticCreep);
938 soft3.addFunc("getPlasticRecovery", &SoftBody3D::getPlasticRecovery);
939 soft3.addFunc("getMaxDeformation", &SoftBody3D::getMaxDeformation);
940 soft3.addFunc("setSelfCollision", &SoftBody3D::setSelfCollision);
941 soft3.addFunc("getSelfCollision", &SoftBody3D::getSelfCollision);
942 soft3.addFunc("setBounds", &SoftBody3D::setBounds);
943 soft3.addFunc("clearBounds", &SoftBody3D::clearBounds);
944 soft3.addFunc("pin", &SoftBody3D::pin);
945 soft3.addFunc("unpin", &SoftBody3D::unpin);
946 soft3.addFunc("isPinned", &SoftBody3D::isPinned);
947 soft3.addFunc("grabAt", &SoftBody3D::grabAt);
948 soft3.addFunc("moveGrab", &SoftBody3D::moveGrab);
949 soft3.addFunc("releaseGrab", &SoftBody3D::releaseGrab);
950 soft3.addFunc("isGrabbing", &SoftBody3D::isGrabbing);
951 soft3.addFunc("getGrabIndex", &SoftBody3D::getGrabIndex);
952 soft3.addFunc("applyForce", &SoftBody3D::applyForce);
953 soft3.addFunc("interactAt", &SoftBody3D::interactAt);
954 soft3.addFunc("setCollideWorld", &SoftBody3D::setCollideWorld);
955 soft3.addFunc("getCollideWorld", &SoftBody3D::getCollideWorld);
956 soft3.addFunc("reset", &SoftBody3D::reset);
957 soft3.addFunc("getCols", &SoftBody3D::getCols);
958 soft3.addFunc("getRows", &SoftBody3D::getRows);
959 soft3.addFunc("getLayers", &SoftBody3D::getLayers);
960 soft3.addFunc("getParticleCount", &SoftBody3D::getParticleCount);
961 soft3.addFunc("getParticleX", &SoftBody3D::getParticleX);
962 soft3.addFunc("getParticleY", &SoftBody3D::getParticleY);
963 soft3.addFunc("getParticleZ", &SoftBody3D::getParticleZ);
964 soft3.addFunc("setParticlePosition", &SoftBody3D::setParticlePosition);
965 soft3.addFunc("getVolumeRatio", &SoftBody3D::getVolumeRatio);
966 soft3.addFunc("destroy", &SoftBody3D::destroy);
967
968 auto soft3Renderer = table.addClass<SoftBody3DRenderer>(
969 "SoftBody3DRenderer", std::function<SoftBody3DRenderer*()>([]() -> SoftBody3DRenderer* { return nullptr; }),
970 true);
971 soft3Renderer.addFunc("setBody", &SoftBody3DRenderer::setBody);
972 soft3Renderer.addFunc("setColor", &SoftBody3DRenderer::setColor);
973 soft3Renderer.addFunc("draw", &SoftBody3DRenderer::draw);
974
975 auto fluid =
976 table.addClass<Fluid2D>("Fluid2D", std::function<Fluid2D*()>([]() -> Fluid2D* { return nullptr; }), true);
977 fluid.addFunc("update", &Fluid2D::update);
978 fluid.addFunc("setGravity", &Fluid2D::setGravity);
979 fluid.addFunc("getGravityX", &Fluid2D::getGravityX);
980 fluid.addFunc("getGravityY", &Fluid2D::getGravityY);
981 fluid.addFunc("setSmoothingRadius", &Fluid2D::setSmoothingRadius);
982 fluid.addFunc("getSmoothingRadius", &Fluid2D::getSmoothingRadius);
983 fluid.addFunc("setRestDensity", &Fluid2D::setRestDensity);
984 fluid.addFunc("getRestDensity", &Fluid2D::getRestDensity);
985 fluid.addFunc("setPressureStiffness", &Fluid2D::setPressureStiffness);
986 fluid.addFunc("getPressureStiffness", &Fluid2D::getPressureStiffness);
987 fluid.addFunc("setNearPressureStiffness", &Fluid2D::setNearPressureStiffness);
988 fluid.addFunc("getNearPressureStiffness", &Fluid2D::getNearPressureStiffness);
989 fluid.addFunc("setViscosity", &Fluid2D::setViscosity);
990 fluid.addFunc("getViscosity", &Fluid2D::getViscosity);
991 fluid.addFunc("setIterations", &Fluid2D::setIterations);
992 fluid.addFunc("getIterations", &Fluid2D::getIterations);
993 fluid.addFunc("setBounds", &Fluid2D::setBounds);
994 fluid.addFunc("clearBounds", &Fluid2D::clearBounds);
995 fluid.addFunc("emit", &Fluid2D::emit);
996 fluid.addFunc("clear", &Fluid2D::clear);
997 fluid.addFunc("interactAt", &Fluid2D::interactAt);
998 fluid.addFunc("setColor", &Fluid2D::setColor);
999 fluid.addFunc("setParticleSize", &Fluid2D::setParticleSize);
1000 fluid.addFunc("getParticleSize", &Fluid2D::getParticleSize);
1001 fluid.addFunc("draw", &Fluid2D::draw);
1002 fluid.addFunc("getCapacity", &Fluid2D::getCapacity);
1003 fluid.addFunc("getParticleCount", &Fluid2D::getParticleCount);
1004 fluid.addFunc("getParticleX", &Fluid2D::getParticleX);
1005 fluid.addFunc("getParticleY", &Fluid2D::getParticleY);
1006 fluid.addFunc("getParticleVx", &Fluid2D::getParticleVx);
1007 fluid.addFunc("getParticleVy", &Fluid2D::getParticleVy);
1008 fluid.addFunc("destroy", &Fluid2D::destroy);
1009}
1010
1011void Physics::expose(ssq::Class& cls) {
1012 const auto vm = cls.getHandle();
1013 cls.addFunc("getName", &Physics::getName);
1014 cls.addFunc("setMeter", &Physics::setMeter);
1015 cls.addFunc("getMeter", &Physics::getMeter);
1016 cls.addFunc("newWorld", &Physics::newWorld);
1017 cls.addFunc("newWorld3D", &Physics::newWorld3D);
1018 cls.addFunc("newWorld3DWithBackend", &Physics::newWorld3DWithBackend);
1019 cls.addFunc("newDistanceField3D", &Physics::newDistanceField3D);
1020 cls.addFunc("distanceField3DFromSdfBlob", [vm](Physics*, ssq::Object object) -> DistanceField3D* {
1021 auto value = script::valueFromSquirrel(object);
1022 if (!value) throw Exception("Physics.distanceField3DFromSdfBlob: invalid Value");
1023 auto blob = decodeSdfField3DBlob(value.value());
1024 if (!blob) throw Exception("Physics.distanceField3DFromSdfBlob: invalid SDF blob");
1026 if (!field) throw Exception("Physics.distanceField3DFromSdfBlob: cannot import VertexGrid blob");
1027 (void)vm;
1028 return new DistanceField3D(std::move(field).takeValue());
1029 });
1030 cls.addFunc("sdfField3DBlobFromDistanceField", [vm](Physics*, DistanceField3D* field) {
1031 if (!field)
1034 "physics.sdf.field3d")));
1036 if (!blob) return script::projectStatusResult(vm, blob.status());
1037 auto encoded = encodeSdfField3DBlob(blob.value());
1038 if (!encoded) return script::projectStatusResult(vm, encoded.status());
1039 return script::projectStatusResult(vm, Status::success(), std::move(encoded).takeValue());
1040 });
1041 cls.addFunc("newSoftBody3D", &Physics::newSoftBody3D);
1042 cls.addFunc("newSoftBody3DRenderer", &Physics::newSoftBody3DRenderer);
1043 cls.addFunc("newFluid2D", &Physics::newFluid2D);
1044}
1045
1046} // namespace eve::physics
double z
double y
double x
HSQUIRRELVM vm
Definition ECS.cpp:38
HSQOBJECT cls
Definition ECS.cpp:39
std::string name
Definition ECS.cpp:154
int rows
int cols
std::vector< std::uint8_t > blob
std::uint32_t capacity
ShaderImageInput shape
std::vector< std::uint32_t > indices
std::vector< Colorf > px
std::uint32_t height
std::uint32_t width
Range range
#define Module_IMPL(ModuleName, newExpr)
Definition Module.h:27
double dt
std::set< std::string > values
std::string body
Object::Ptr value
int created
int count
The single Squirrel projection for common Result, Status and Value.
std::array< double, 2 > vertices[3]
int spacing
std::uint32_t depth
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
EVENGINE_API_FOUNDATION public API.
Definition Exception.h:13
virtual std::string getName() const =0
Returns the name.
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.cpp:19
static Status failure(StatusCode code, Diagnostic diagnostic)
Construct a failed status with one diagnostic.
Definition Status.cpp:28
The canonical owning dynamic value used by data-facing protocols.
Definition Value.h:31
bool isAngularYLocked() const
Whether rotation around Y is locked.
Definition Body3D.cpp:316
void setActive(bool active)
Disables/enables the body and its shapes.
Definition Body3D.cpp:408
bool isAngularXLocked() const
Whether rotation around X is locked.
Definition Body3D.cpp:312
void setRotation(float qx, float qy, float qz, float qw)
Orientation as quaternion (x, y, z, w).
Definition Body3D.cpp:109
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:179
float getInertiaYZ() const
Local symmetric inertia tensor YZ component.
Definition Body3D.cpp:355
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:186
float getLocalCenterY() const
Local center of mass Y coordinate.
Definition Body3D.cpp:363
bool isBullet() const
True when bullet.
Definition Body3D.cpp:420
void setAngularDamping(float damping)
Angular damping coefficient, finite and non-negative.
Definition Body3D.cpp:263
bool isAngularZLocked() const
Whether rotation around Z is locked.
Definition Body3D.cpp:320
bool isActive() const
True when active.
Definition Body3D.cpp:412
void applyForce(float fx, float fy, float fz)
Force applied at the center of mass.
Definition Body3D.cpp:201
float getWorldCenterX() const
World center of mass X coordinate.
Definition Body3D.cpp:371
float getLinearVelocityY() const
Returns the linear velocity y.
Definition Body3D.cpp:137
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:165
void applyLinearImpulse(float ix, float iy, float iz)
Instantaneous linear impulse.
Definition Body3D.cpp:213
void setFixedRotation(bool fixed)
Lock all angular axes (Box3D motion locks).
Definition Body3D.cpp:400
void applyAngularImpulse(float ix, float iy, float iz)
Instantaneous angular impulse.
Definition Body3D.cpp:221
float getInertiaYY() const
Local inertia tensor YY component about the center of mass.
Definition Body3D.cpp:339
float getAngularDamping() const
Current angular damping coefficient.
Definition Body3D.cpp:267
float getX() const
Returns the x.
Definition Body3D.cpp:97
void setLinearDamping(float damping)
Linear damping coefficient, finite and non-negative.
Definition Body3D.cpp:255
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:172
void applyLocalForceToCenter(float fx, float fy, float fz)
Body-local force applied at the center of mass.
Definition Body3D.cpp:229
bool isLinearYLocked() const
Whether translation along Y is locked.
Definition Body3D.cpp:304
float getMass() const
Body mass in kg.
Definition Body3D.cpp:145
bool isFixedRotation() const
True when fixed rotation.
Definition Body3D.cpp:404
void setBullet(bool bullet)
CCD bullet mode.
Definition Body3D.cpp:416
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:440
void applyLocalTorque(float tx, float ty, float tz)
Body-local torque.
Definition Body3D.cpp:233
float getY() const
Returns the y.
Definition Body3D.cpp:101
void setAwake(bool awake)
Wakes / sleeps the body manually.
Definition Body3D.cpp:424
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:217
float getLinearDamping() const
Current linear damping coefficient.
Definition Body3D.cpp:259
float getInertiaXZ() const
Local symmetric inertia tensor XZ component.
Definition Body3D.cpp:351
void destroy()
Destroys the body inside its world.
Definition Body3D.cpp:65
float getRotZ() const
Returns the rot z.
Definition Body3D.cpp:121
float getSleepThreshold() const
Current sleep velocity threshold.
Definition Body3D.cpp:291
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:324
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:250
float getRotY() const
Returns the rot y.
Definition Body3D.cpp:117
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:225
bool isLinearZLocked() const
Whether translation along Z is locked.
Definition Body3D.cpp:308
float getGravityScale() const
Current world-gravity multiplier.
Definition Body3D.cpp:275
float getLocalCenterZ() const
Local center of mass Z coordinate.
Definition Body3D.cpp:367
float getRotX() const
Returns the rot x.
Definition Body3D.cpp:113
bool isLinearXLocked() const
Whether translation along X is locked.
Definition Body3D.cpp:300
float getAngularVelocityZ() const
Returns the angular velocity z.
Definition Body3D.cpp:161
void setSleepEnabled(bool enabled)
Enables or disables automatic sleeping for this body.
Definition Body3D.cpp:279
int getId() const
Stable id used by collision events.
Definition Body3D.h:42
void applyLocalLinearImpulseToCenter(float ix, float iy, float iz)
Body-local linear impulse applied at the center of mass.
Definition Body3D.cpp:242
float getAngularVelocityX() const
Returns the angular velocity x.
Definition Body3D.cpp:153
std::string getType() const
Returns the type.
Definition Body3D.cpp:396
float getRotW() const
Returns the rot w.
Definition Body3D.cpp:125
void applyTorque(float tx, float ty, float tz)
Torque applied in world space.
Definition Body3D.cpp:209
bool isSleepEnabled() const
Whether automatic sleeping is enabled.
Definition Body3D.cpp:283
float getInertiaXX() const
Local inertia tensor XX component about the center of mass.
Definition Body3D.cpp:335
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:295
void applyForceAt(float fx, float fy, float fz, float x, float y, float z)
Force applied at a world position.
Definition Body3D.cpp:205
void resetMassProperties()
Restores automatic mass, center, and inertia calculation from attached shapes.
Definition Body3D.cpp:331
float getInertiaXY() const
Local symmetric inertia tensor XY component.
Definition Body3D.cpp:347
float getWorldCenterZ() const
World center of mass Z coordinate.
Definition Body3D.cpp:379
float getInertiaZZ() const
Local inertia tensor ZZ component about the center of mass.
Definition Body3D.cpp:343
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:454
void setLinearVelocity(float vx, float vy, float vz)
Linear velocity in m/s.
Definition Body3D.cpp:129
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:237
float getWorldCenterY() const
World center of mass Y coordinate.
Definition Body3D.cpp:375
void setGravityScale(float scale)
Multiplier applied to world gravity; may be negative.
Definition Body3D.cpp:271
bool isAwake() const
True when awake.
Definition Body3D.cpp:428
void setPosition(float x, float y, float z)
Position in meters.
Definition Body3D.cpp:93
void setType(const std::string &bodyType)
"static" | "kinematic" | "dynamic".
Definition Body3D.cpp:383
float getLocalCenterX() const
Local center of mass X coordinate.
Definition Body3D.cpp:359
float getLinearVelocityZ() const
Returns the linear velocity z.
Definition Body3D.cpp:141
std::vector< float > getWorldPointVelocity(float x, float y, float z) const
World-space velocity at the supplied world point.
Definition Body3D.cpp:197
void setAngularVelocity(float wx, float wy, float wz)
Angular velocity in rad/s.
Definition Body3D.cpp:149
void setSleepThreshold(float threshold)
Sleep velocity threshold, finite and non-negative.
Definition Body3D.cpp:287
float getAngularVelocityY() const
Returns the angular velocity y.
Definition Body3D.cpp:157
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:190
float getZ() const
Returns the z.
Definition Body3D.cpp:105
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:448
float getLinearVelocityX() const
Returns the linear velocity x.
Definition Body3D.cpp:133
void applyLocalAngularImpulse(float ix, float iy, float iz)
Body-local angular impulse.
Definition Body3D.cpp:246
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:230
float getLinearVelocityX() const
Returns the linear velocity x.
Definition Body.cpp:132
void applyForceAt(float fx, float fy, float x, float y)
Force applied at a world pixel position.
Definition Body.cpp:175
void setBullet(bool bullet)
CCD bullet mode (recommended for fast small bodies).
Definition Body.cpp:216
float getX() const
Returns the x.
Definition Body.cpp:107
void setAwake(bool awake)
Wakes / sleeps the body manually.
Definition Body.cpp:223
void setType(const std::string &bodyType)
"static" | "kinematic" | "dynamic".
Definition Body.cpp:192
void setAngle(float radians)
Rotation in radians.
Definition Body.cpp:117
float getLinearVelocityY() const
Returns the linear velocity y.
Definition Body.cpp:137
bool isActive() const
True when active.
Definition Body.cpp:214
void applyLinearImpulse(float ix, float iy)
Instantaneous linear impulse.
Definition Body.cpp:181
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:258
void setFixedRotation(bool fixed)
Locks rotation so the body cannot spin.
Definition Body.cpp:202
void applyForce(float fx, float fy)
Force (pixels/s² * kg) applied at the center of mass.
Definition Body.cpp:169
bool isAwake() const
True when awake.
Definition Body.cpp:228
bool isFixedRotation() const
True when fixed rotation.
Definition Body.cpp:207
bool isBullet() const
True when bullet.
Definition Body.cpp:221
void setAngularVelocity(float omega)
Angular velocity in radians/s.
Definition Body.cpp:159
float getAngularVelocity() const
Returns the angular velocity.
Definition Body.cpp:164
void destroy()
Destroys the body inside its world.
Definition Body.cpp:73
void applyAngularImpulse(float impulse)
Instantaneous angular impulse.
Definition Body.cpp:187
float getWorldCenterY() const
Returns the world center y.
Definition Body.cpp:154
float getLinearSpeed() const
Magnitude of the linear velocity.
Definition Body.cpp:142
float getAngle() const
Returns the angle.
Definition Body.cpp:122
std::string getType() const
Returns the type.
Definition Body.cpp:197
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:102
float getWorldCenterX() const
World center of mass in pixels.
Definition Body.cpp:149
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:235
float getMass() const
Mass in kilograms (Box2D units).
Definition Body.cpp:147
void setActive(bool active)
Disables/enables the body and its fixtures.
Definition Body.cpp:209
void setLinearVelocity(float vx, float vy)
Linear velocity in pixels/s.
Definition Body.cpp:127
float getY() const
Returns the y.
Definition Body.cpp:112
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
float getConstraintForceX() const
Current world-space constraint force X in newtons.
Definition Joint3D.cpp:92
void setDistanceLength(float length)
Changes distance-joint rest length in metres.
Definition Joint3D.cpp:124
float getConstraintForceY() const
Current world-space constraint force Y in newtons.
Definition Joint3D.cpp:96
float getParallelHertz() const
Parallel spring stiffness in Hertz.
Definition Joint3D.cpp:227
void destroy()
Destroys the backend joint and invalidates this wrapper.
Definition Joint3D.cpp:39
void setForceThreshold(float threshold)
Sets the force threshold that emits a joint-stress event, in newtons.
Definition Joint3D.cpp:75
float getDistanceLength() const
Distance-joint rest length in metres.
Definition Joint3D.cpp:125
void setWheelSteering(bool enabled, float targetAngle, float hertz, float dampingRatio, float maxTorque)
Configures steering target, stiffness, damping and maximum torque.
Definition Joint3D.cpp:182
void setMotorVelocityLimits(float maxForce, float maxTorque)
Sets motor velocity force/torque limits.
Definition Joint3D.cpp:209
void setWheelSpinMotor(bool enabled, float speed, float maxTorque)
Configures wheel spin motor speed and maximum torque.
Definition Joint3D.cpp:179
void setSphericalTwistLimits(bool enabled, float lower, float upper)
Enables spherical twist limits in radians.
Definition Joint3D.cpp:164
float getTorqueThreshold() const
Current torque event threshold in newton-metres.
Definition Joint3D.cpp:87
float getParallelMaxTorque() const
Parallel maximum spring torque in newton-metres.
Definition Joint3D.cpp:229
float getWheelSpinTorque() const
Current wheel spin motor torque in newton-metres.
Definition Joint3D.cpp:190
void setRevoluteLimits(bool enabled, float lower, float upper)
Configures revolute angular limits in radians.
Definition Joint3D.cpp:140
void setDistanceMotor(bool enabled, float speed, float maxForce)
Configures the distance motor in metres/second and newtons.
Definition Joint3D.cpp:133
float getRevoluteMotorTorque() const
Current revolute motor torque in newton-metres.
Definition Joint3D.cpp:147
void setMotorAngularVelocity(float wx, float wy, float wz)
Sets motor-joint relative angular velocity in radians/second.
Definition Joint3D.cpp:206
float getForceThreshold() const
Current force event threshold in newtons.
Definition Joint3D.cpp:79
float getParallelDampingRatio() const
Parallel spring damping ratio.
Definition Joint3D.cpp:228
void setSphericalMotor(bool enabled, float velocityX, float velocityY, float velocityZ, float maxTorque)
Configures spherical motor velocity and maximum torque.
Definition Joint3D.cpp:167
float getWeldAngularHertz() const
Weld angular stiffness in Hertz.
Definition Joint3D.cpp:201
float getWeldLinearDampingRatio() const
Weld linear damping ratio.
Definition Joint3D.cpp:200
void setTorqueThreshold(float threshold)
Sets the torque threshold that emits a joint-stress event, in newton-metres.
Definition Joint3D.cpp:83
void setWeldLinearSpring(float hertz, float dampingRatio)
Configures weld linear spring stiffness and damping; 0 hertz is rigid.
Definition Joint3D.cpp:193
float getDistanceCurrentLength() const
Current anchor-to-anchor distance in metres.
Definition Joint3D.cpp:126
float getPrismaticTranslation() const
Current prismatic translation in metres.
Definition Joint3D.cpp:158
float getRevoluteAngle() const
Current revolute angle in radians.
Definition Joint3D.cpp:146
void setDistanceLimits(bool enabled, float minimum, float maximum)
Configures optional distance limits in metres.
Definition Joint3D.cpp:130
float getConstraintTorqueZ() const
Current world-space constraint torque Z in newton-metres.
Definition Joint3D.cpp:112
float getWheelSpinSpeed() const
Current wheel spin speed in radians/second.
Definition Joint3D.cpp:189
int getId() const
Stable world-local identifier.
Definition Joint3D.h:45
void setWheelSteeringLimits(bool enabled, float lower, float upper)
Configures steering angular limits in radians.
Definition Joint3D.cpp:186
float getPrismaticMotorForce() const
Current prismatic motor force in newtons.
Definition Joint3D.cpp:160
void setRevoluteSpring(bool enabled, float targetAngle, float hertz, float dampingRatio)
Configures a revolute angular spring in radians.
Definition Joint3D.cpp:136
void setPrismaticLimits(bool enabled, float lower, float upper)
Configures prismatic translation limits in metres.
Definition Joint3D.cpp:152
std::string getKind() const
Joint kind string for script/debug ("distance", "revolute", …, "filter").
Definition Joint3D.cpp:43
float getMotorLinearVelocityX() const
Desired motor linear velocity X in metres/second.
Definition Joint3D.cpp:218
void setParallelSpring(float hertz, float dampingRatio, float maxTorque)
Configures parallel-joint spring stiffness, damping and torque cap.
Definition Joint3D.cpp:224
void setMotorLinearVelocity(float vx, float vy, float vz)
Sets motor-joint relative linear velocity in metres/second.
Definition Joint3D.cpp:203
float getMotorAngularVelocityY() const
Desired motor angular velocity Y in radians/second.
Definition Joint3D.cpp:222
float getLinearSeparation() const
Current inadmissible linear separation error in metres.
Definition Joint3D.cpp:116
float getMotorAngularVelocityX() const
Desired motor angular velocity X in radians/second.
Definition Joint3D.cpp:221
float getWheelSteeringTorque() const
Current steering torque in newton-metres.
Definition Joint3D.cpp:192
float getMotorAngularVelocityZ() const
Desired motor angular velocity Z in radians/second.
Definition Joint3D.cpp:223
float getWeldLinearHertz() const
Weld linear stiffness in Hertz.
Definition Joint3D.cpp:199
float getWeldAngularDampingRatio() const
Weld angular damping ratio.
Definition Joint3D.cpp:202
float getConstraintTorqueX() const
Current world-space constraint torque X in newton-metres.
Definition Joint3D.cpp:104
float getConstraintForceZ() const
Current world-space constraint force Z in newtons.
Definition Joint3D.cpp:100
float getMotorLinearVelocityY() const
Desired motor linear velocity Y in metres/second.
Definition Joint3D.cpp:219
float getAngularSeparation() const
Current inadmissible angular separation error in radians.
Definition Joint3D.cpp:120
float getMotorLinearVelocityZ() const
Desired motor linear velocity Z in metres/second.
Definition Joint3D.cpp:220
float getWheelSteeringAngle() const
Current wheel steering angle in radians.
Definition Joint3D.cpp:191
void setDistanceSpring(bool enabled, float hertz, float dampingRatio)
Configures a distance spring; hertz and damping must be non-negative.
Definition Joint3D.cpp:127
void setRevoluteMotor(bool enabled, float speed, float maxTorque)
Configures the revolute motor in radians/second and newton-metres.
Definition Joint3D.cpp:143
int getBodyAId() const
Stable ID of attached body A, or -1 after invalidation.
Definition Joint3D.cpp:58
void setWheelSuspensionLimits(bool enabled, float lower, float upper)
Configures wheel suspension travel limits in metres.
Definition Joint3D.cpp:176
float getPrismaticSpeed() const
Current prismatic translation speed in metres/second.
Definition Joint3D.cpp:159
bool getCollideConnected() const
Whether attached bodies may collide.
Definition Joint3D.cpp:71
void setMotorAngularSpring(float hertz, float dampingRatio, float maxTorque)
Configures motor angular position spring.
Definition Joint3D.cpp:215
float getSphericalConeAngle() const
Current spherical cone angle in radians.
Definition Joint3D.cpp:171
void setPrismaticMotor(bool enabled, float speed, float maxForce)
Configures a prismatic motor in metres/second and newtons.
Definition Joint3D.cpp:155
void setSphericalConeLimit(bool enabled, float angle)
Enables a spherical cone limit in radians, within [0, pi].
Definition Joint3D.cpp:161
void setWeldAngularSpring(float hertz, float dampingRatio)
Configures weld angular spring stiffness and damping; 0 hertz is rigid.
Definition Joint3D.cpp:196
int getBodyBId() const
Stable ID of attached body B, or -1 after invalidation.
Definition Joint3D.cpp:59
void setWheelSuspension(bool enabled, float hertz, float dampingRatio)
Configures wheel suspension spring stiffness and damping.
Definition Joint3D.cpp:173
void setPrismaticSpring(bool enabled, float targetTranslation, float hertz, float dampingRatio)
Configures a prismatic linear spring and target translation.
Definition Joint3D.cpp:148
float getConstraintTorqueY() const
Current world-space constraint torque Y in newton-metres.
Definition Joint3D.cpp:108
float getSphericalTwistAngle() const
Current spherical twist angle in radians.
Definition Joint3D.cpp:172
void setCollideConnected(bool collide)
Enables or disables collision between the attached bodies.
Definition Joint3D.cpp:67
void setMotorLinearSpring(float hertz, float dampingRatio, float maxForce)
Configures motor linear position spring.
Definition Joint3D.cpp:212
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.
static SSQ_REG PhysicsBakeRecording * create()
Borrow the stateless compatibility facade for the Squirrel factory ABI. @ownership Process-owned; no ...
static SSQ_REG PhysicsBake * create()
Borrow the stateless compatibility facade for the Squirrel factory ABI. @ownership Process-owned; no ...
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:48
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.
World3D * newWorld3DWithBackend(const std::string &backend, float gravityX, float gravityY, float gravityZ, bool sleep=true)
Compatibility script factory selecting "box3d" or "jolt" explicitly.
void setMeter(float pixelsPerMeter)
Pixels per meter for 2D Box2D worlds (default 30, same as LÖVE).
Definition Physics.cpp:41
SoftBody3DRenderer * newSoftBody3DRenderer(SoftBody3D *body)
Create a presentation satellite observing a soft-body runtime.
Definition Physics.cpp:60
Fluid2D * newFluid2D(int capacity=512)
Creates an interactive 2D particle fluid in pixel space.
Definition Physics.cpp:62
float getMeter() const
Returns the meter.
Definition Physics.cpp:46
World * newWorld(float gravityX, float gravityY, bool sleep=true)
Create a 2D Box2D physics world.
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:53
int getId() const
Stable world-local id, preserved when sensor state recreates the backend shape.
Definition Shape3D.h:48
float getHeightFieldCellSizeZ() const
Height-field cell spacing along local Z, or zero.
Definition Shape3D.h:151
void setLocalPosition(float x, float y, float z)
Sets local translation while preserving local rotation.
Definition Shape3D.cpp:487
void setDensity(float density)
Definition Shape3D.cpp:604
void setTag(int tag)
User-defined integer tag preserved for the wrapper lifetime.
Definition Shape3D.cpp:120
void setBoxSize(float width, float height, float depth)
Atomically changes full box dimensions in meters.
Definition Shape3D.cpp:198
int getHeightFieldCountZ() const
Height-field sample count along local Z, or zero.
Definition Shape3D.h:145
float getTriangleMeshMaterialRestitution(int slot) const
Restitution of a triangle-mesh material slot.
Definition Shape3D.cpp:387
int getTriangleMeshMaterialId(int slot) const
Application material ID of a triangle-mesh material slot.
Definition Shape3D.cpp:401
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:134
float getLocalZ() const
Local translation Z in meters.
Definition Shape3D.h:211
int getTriangleMeshVertexCount() const
Source vertex count for a triangle mesh, or zero.
Definition Shape3D.h:96
std::string getKind() const
Kind name including primitives, "convexHull", "triangleMesh", or "heightField".
Definition Shape3D.cpp:186
bool testPoint(float x, float y, float z) const
Point-in-shape test in world meters.
Definition Shape3D.cpp:648
void setHitEventsEnabled(bool enabled)
Enables significant collision hit events for this shape.
Definition Shape3D.cpp:125
void setMaterialId(int id)
Sets a low-32-bit application material identifier exposed by native queries.
Definition Shape3D.cpp:550
int getTriangleMeshMaterialIndex(int triangleIndex) const
Material-slot index assigned to a source triangle.
Definition Shape3D.cpp:335
float getLocalRotX() const
Normalized local quaternion X.
Definition Shape3D.h:213
int getTag() const
User-defined integer tag, zero by default.
Definition Shape3D.h:54
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:350
float getHeightFieldHeight(int x, int z) const
Source height at a grid sample.
Definition Shape3D.cpp:441
int getTriangleMeshMaterialCount() const
Number of material slots on a triangle mesh, otherwise zero.
Definition Shape3D.cpp:346
float getTangentVelocityY() const
Local-space conveyor velocity Y component.
Definition Shape3D.cpp:542
float getTriangleMeshMaterialRollingResistance(int slot) const
Rolling resistance of a triangle-mesh material slot.
Definition Shape3D.cpp:393
bool isSensor() const
Definition Shape3D.cpp:495
void setRestitution(float restitution)
Definition Shape3D.cpp:506
float getLocalY() const
Local translation Y in meters.
Definition Shape3D.h:209
void setSphereRadius(float radius)
Atomically changes sphere radius in meters.
Definition Shape3D.cpp:217
float getBoxHeight() const
Full box height, or zero for another geometry kind.
Definition Shape3D.h:165
float getLocalX() const
Local translation X in meters.
Definition Shape3D.h:207
bool isOneWay() const
Whether one-way pre-solve filtering is requested.
Definition Shape3D.h:189
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:450
void setGroupIndex(int index)
Collision group; negative never collides, positive always collides.
Definition Shape3D.cpp:639
float getTriangleMeshMaterialFriction(int slot) const
Friction of a triangle-mesh material slot.
Definition Shape3D.cpp:381
float getBoxWidth() const
Full box width, or zero for another geometry kind.
Definition Shape3D.h:163
float getHeightFieldGlobalMin() const
Height-field shared quantization minimum, or zero.
Definition Shape3D.h:155
float getFriction() const
Definition Shape3D.cpp:504
float getRestitution() const
Definition Shape3D.cpp:513
void setFrictionCombineMode(const std::string &mode)
Sets friction combine mode: default, average, minimum, multiply, or maximum.
Definition Shape3D.cpp:558
void destroy()
Destroys the shape inside its world.
Definition Shape3D.cpp:77
void setLocalRotation(float qx, float qy, float qz, float qw)
Sets local rotation while preserving local translation.
Definition Shape3D.cpp:491
float getLocalRotW() const
Normalized local quaternion scalar component.
Definition Shape3D.h:219
void setTangentVelocity(float x, float y, float z)
Sets local-space conveyor velocity projected onto contact surfaces.
Definition Shape3D.cpp:529
float getExplosionScale() const
Current explosion impulse multiplier; zero opts this shape out.
Definition Shape3D.h:251
int getMaterialId() const
Low-32-bit application material identifier.
Definition Shape3D.cpp:586
float getCapsuleHeight() const
Capsule hemisphere-center distance, or zero for another kind.
Definition Shape3D.h:173
float getBoxDepth() const
Full box depth, or zero for another geometry kind.
Definition Shape3D.h:167
int getHeightFieldCountX() const
Height-field sample count along local X, or zero.
Definition Shape3D.h:143
void setCapsuleSize(float height, float radius)
Atomically changes capsule segment height and radius in meters.
Definition Shape3D.cpp:230
float getHeightFieldCellSizeX() const
Height-field cell spacing along local X, or zero.
Definition Shape3D.h:147
float getDensity() const
Definition Shape3D.cpp:611
int getGroupIndex() const
Definition Shape3D.cpp:646
float getLocalRotZ() const
Normalized local quaternion Z.
Definition Shape3D.h:217
float getHeightFieldGlobalMax() const
Height-field shared quantization maximum, or zero.
Definition Shape3D.h:159
void setRestitutionCombineMode(const std::string &mode)
Sets restitution combine mode: default, average, minimum, multiply, or maximum.
Definition Shape3D.cpp:572
float getTangentVelocityZ() const
Local-space conveyor velocity Z component.
Definition Shape3D.cpp:546
int getTriangleMeshTriangleCount() const
Source triangle count for a triangle mesh, or zero.
Definition Shape3D.h:100
std::string getRestitutionCombineMode() const
Current restitution combine mode.
Definition Shape3D.cpp:581
void setRollingResistance(float resistance)
Rolling resistance coefficient, finite and non-negative.
Definition Shape3D.cpp:515
void disableOneWay()
Disables one-way filtering and restores ordinary two-sided collision.
Definition Shape3D.cpp:158
void setSensor(bool sensor)
Sensor shapes report contacts but never collide.
Definition Shape3D.cpp:102
int getConvexHullPointCount() const
Source point count for a convex hull, or zero for another kind.
Definition Shape3D.h:82
float getLocalRotY() const
Normalized local quaternion Y.
Definition Shape3D.h:215
std::string getFrictionCombineMode() const
Current friction combine mode.
Definition Shape3D.cpp:567
bool areHitEventsEnabled() const
Whether significant collision hit events are enabled.
Definition Shape3D.cpp:130
void setFriction(float friction)
Material properties.
Definition Shape3D.cpp:497
void setExplosionScale(float scale)
Sets non-negative multiplier applied to geometry-aware explosion impulses.
Definition Shape3D.cpp:590
float getRadius() const
Sphere/capsule radius, or zero for a box.
Definition Shape3D.h:169
int getConvexHullMaxVertices() const
Current convex-hull simplification budget, or zero for another kind.
Definition Shape3D.h:86
float getTangentVelocityX() const
Local-space conveyor velocity X component.
Definition Shape3D.cpp:538
float getRollingResistance() const
Current rolling resistance; physically affects spheres and capsules.
Definition Shape3D.cpp:525
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.
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.
bool hasClosestPoint() const
Whether the latest closestPoint call found a shape.
Definition World3D.h:687
int getBeginTriggerVisitorShapeId(int index) const
Visitor shape ID of a begin-trigger event.
float getProfileStepMs() const
Latest complete physics step time in milliseconds.
Definition World3D.cpp:223
float getRestitutionThreshold() const
Current restitution speed threshold in m/s.
Definition World3D.cpp:128
void setGravity(float gx, float gy, float gz)
Gravity in m/s².
Definition World3D.cpp:318
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:722
int getEndTriggerCount() const
Number of sensor overlaps that ended during the latest step.
Definition World3D.h:860
int getQueryBodyId(int index) const
Body id of the i-th query hit.
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:691
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:530
float getHitNormalX(int index) const
Hit normal X, pointing from stable side A to B.
int getDynamicTreeHeight() const
Dynamic broad-phase tree height.
Definition World3D.cpp:215
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.
bool hasRayHit() const
Definition World3D.h:521
bool isWarmStartingEnabled() const
Whether constraint warm starting is enabled.
Definition World3D.cpp:153
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:147
float getClosestY() const
Closest surface point Y.
Definition World3D.h:697
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:220
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:223
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...
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).
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...
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:693
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.
Definition World3D.cpp:205
int getShapeCastShapeId() const
Stable shape id from the last shape cast, or -1.
Definition World3D.h:714
int getRayResultTriangleIndex(int index) const
Mesh/height-field triangle index of a sorted ray result, otherwise -1.
float getRayHitX() const
Definition World3D.h:531
float getShapeCastZ() const
World-space contact point Z from the last shape cast.
Definition World3D.h:726
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.
int getBeginContactBodyBId(int index) const
Body ID on stable side B of a begin-contact event.
float getRayHitY() const
Definition World3D.h:532
int getContactPointOtherShapeId(int index) const
Other Shape ID of a contact point.
float getContactDampingRatio() const
Current contact damping ratio.
Definition World3D.h:221
float getMoverNormalY() const
Representative blocking normal Y from the last move.
Definition World3D.h:789
int getQueryShapeCount() const
Number of individual shapes hit by the last overlap query.
Definition World3D.h:810
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:190
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.
float getGravityX() const
Definition World3D.cpp:321
int getQueryCount() const
Number of bodies hit by the last overlap query.
Definition World3D.h:806
float getRayResultNormalY(int index) const
Surface normal Y of a sorted ray result.
float getProfileBulletsMs() const
Latest continuous-collision bullet time in milliseconds.
Definition World3D.cpp:231
void setBodyPairCollisionEnabled(Body3D *bodyA, Body3D *bodyB, bool enabled)
Overrides collision for a live body pair without changing layer masks.
Definition World3D.cpp:341
float getContactHertz() const
Current contact stiffness frequency.
Definition World3D.h:219
float getRayHitNormalX() const
Definition World3D.h:534
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:701
int getQueryMaskBits() const
Query mask bits currently in use.
Definition World3D.h:989
int getQueryShapeTag(int index) const
User tag paired with the i-th shape hit.
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:785
float getProfileCollideMs() const
Latest narrow-phase collision time in milliseconds.
Definition World3D.cpp:227
void setMoverUp(float x, float y, float z)
Set the up direction used for grounded and slope classification.
int getHitCount() const
Number of significant collision hits generated during the latest step.
Definition World3D.h:931
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.
std::string queryToken() const
Opaque process-local query token; re-fetch after restore, never persist in save data.
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:716
float getRayHitNormalZ() const
Definition World3D.h:536
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.
float getMoverDeltaY() const
Resolved translation Y from the last moveCapsule call.
Definition World3D.h:783
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:846
void setContactTuning(float hertz, float dampingRatio, float pushOutSpeed)
Configures contact overlap recovery.
Definition World3D.cpp:131
bool isBodyPairCollisionEnabled(Body3D *bodyA, Body3D *bodyB) const
Whether a body pair is permitted by the runtime contact override.
Definition World3D.cpp:358
int queryBodyContacts(int bodyId, int maxPoints)
Compatibility cache adapter over queryBodyContactsOwned for script callers. Results are oriented from...
void setQueryIgnoredBodyId(int bodyId)
Ignores one stable Body3D ID in subsequent spatial queries; -1 disables.
Definition World3D.cpp:480
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:987
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,...
float getMoverNormalZ() const
Representative blocking normal Z from the last move.
Definition World3D.h:791
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:707
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:122
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.
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:732
void setWarmStartingEnabled(bool enabled)
Enables constraint warm starting for stable stacks and joints.
Definition World3D.cpp:150
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:817
int getJointStressBodyAId(int index) const
Stable body A ID of a stress event.
float getGravityY() const
Definition World3D.cpp:324
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:831
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:380
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.
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....
int getJointStressCount() const
Number of joints exceeding force/torque thresholds in the latest step.
Definition World3D.h:961
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:156
int getShapeCastTriangleIndex() const
Mesh/height-field triangle index from the latest shape cast, otherwise -1.
Definition World3D.h:720
void setQueryFilter(int categoryBits, int maskBits)
Set category/mask bits for subsequent ray, overlap, cast and mover queries.
Definition World3D.cpp:470
float getMoverDeltaX() const
Resolved translation X from the last moveCapsule call.
Definition World3D.h:781
int getShapeCastMaterialId() const
Surface material ID at the last shape-cast intersection, or zero.
Definition World3D.h:718
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:699
float getBoundsMaxZ() const
Maximum world-space Z covered by current broad-phase bounds.
Definition World3D.cpp:196
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].
int getIslandCount() const
Current solver-island count.
Definition World3D.cpp:207
void setHitEventThreshold(float speed)
Minimum approach speed in m/s required for enabled Shape3D hit events.
Definition World3D.cpp:330
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.
int getStaticTreeHeight() const
Static broad-phase tree height.
Definition World3D.cpp:213
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:689
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.
Definition World3D.cpp:217
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:997
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:712
float getShapeCastY() const
World-space contact point Y from the last shape cast.
Definition World3D.h:724
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.
void setMaximumLinearSpeed(float speed)
Sets the finite positive world-wide linear velocity clamp in m/s.
Definition World3D.cpp:144
float getBoundsMinY() const
Minimum world-space Y covered by current broad-phase bounds.
Definition World3D.cpp:188
int getRayHitMaterialId() const
Surface material ID at the last ray intersection, or zero.
Definition World3D.h:528
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:705
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:250
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:526
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.
float getProfileSensorsMs() const
Latest sensor processing time in milliseconds.
Definition World3D.cpp:233
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.
Definition World3D.cpp:199
float getBoundsMinX() const
Minimum world-space X covered by current broad-phase bounds.
Definition World3D.cpp:186
int getAwakeContactCount() const
Contacts processed by the latest collide pass.
Definition World3D.cpp:209
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:703
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.
void setRestitutionThreshold(float speed)
Minimum impact speed that permits material restitution, in m/s.
Definition World3D.cpp:125
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.
float getContactRecycleDistance() const
Current contact-point persistence distance in meters.
Definition World3D.cpp:141
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...
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.
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.
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:497
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:117
void setQueryIgnoredShapeId(int shapeId)
Ignores one stable Shape3D ID in subsequent spatial queries; -1 disables.
Definition World3D.cpp:486
float getShapeCastFraction() const
Translation fraction in [0,1] at the earliest hit.
Definition World3D.h:734
void clearQueryIgnores()
Clears Body and Shape query exclusions without changing layer filtering.
Definition World3D.cpp:492
float getBoundsMaxX() const
Maximum world-space X covered by current broad-phase bounds.
Definition World3D.cpp:192
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:728
int getContactCount() const
Current backend contact count.
Definition World3D.cpp:203
int getQueryIgnoredBodyId() const
Stable Body3D ID currently ignored by queries, or -1.
Definition World3D.h:995
int getContactPointCount() const
Number of points cached by queryBodyContacts.
Definition World3D.h:896
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:327
float getProfileSolveMs() const
Latest constraint solver time in milliseconds.
Definition World3D.cpp:229
void clearContactEvents()
Clears all contact and trigger buffers before the next step.
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:241
float getRayHitZ() const
Definition World3D.h:533
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:730
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.
Definition World3D.cpp:225
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:710
void resetQueryFilter()
Restore the query filter to accept all lower-32-bit categories.
Definition World3D.cpp:475
void setShapePairCollisionEnabled(Shape3D *shapeA, Shape3D *shapeB, bool enabled)
Overrides collision for one live shape pair.
Definition World3D.cpp:366
int getRayHitBodyId() const
Definition World3D.h:522
bool isContactPointPersisted(int index) const
Whether this manifold point existed in the previous step.
float getClosestX() const
Closest surface point X.
Definition World3D.h:695
float getMoverNormalX() const
Representative blocking normal X from the last move.
Definition World3D.h:787
float getHitEventThreshold() const
Current significant-hit speed threshold in m/s.
Definition World3D.cpp:333
int getRecycledContactCount() const
Contact points recycled during the latest step.
Definition World3D.cpp:211
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:539
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.
Body3D * newBody(const std::string &bodyType, float x, float y, float z)
Creates a body in meter-space units.
Definition World3D.cpp:422
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:194
void setContactRecycleDistance(float distance)
Sets contact-point persistence distance in meters; zero disables recycling.
Definition World3D.cpp:136
float getRayResultNormalZ(int index) const
Surface normal Z of a sorted ray result.
float getRayHitFraction() const
Definition World3D.h:537
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...
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:795
float getRayResultY(int index) const
World-space hit point Y of a sorted ray result.
float getRayHitNormalY() const
Definition World3D.h:535
int getShapeCastResultCount() const
Number of results cached by the latest single or multi Shape Cast.
Definition World3D.h:736
int getMoverPlaneCount() const
Number of collision planes considered during the last move.
Definition World3D.h:793
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.
Definition World3D.cpp:201
int getRayHitShapeId() const
Stable shape id from the last ray cast, or -1.
Definition World3D.h:524
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:803
bool isMoverGrounded() const
True when the last move touched a walkable plane.
Definition World3D.h:801
float getRayResultZ(int index) const
World-space hit point Z of a sorted ray result.
void setMeter(float pixelsPerMeter)
Changes the pixels-per-meter conversion.
Definition World.cpp:462
float getRayHitX() const
Definition World.h:350
int getRayHitBodyId() const
Definition World.h:349
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.
int getEndTriggerCount() const
Sensor/visitor end overlaps collected during the last step.
Definition World.h:383
int getEndTriggerSensorBodyId(int index) const
Definition World.cpp:703
void update(float dt)
Steps the simulation by dt seconds (5 velocity / 2 position iterations).
Definition World.cpp:394
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:814
float getImpactNormalY(int index) const
Definition World.cpp:743
int getBeginTriggerCount() const
Sensor/visitor begin overlaps collected during the last step (2D parity with World3D).
Definition World.h:377
void destroyBody(Body *body)
Destroys a body (null is ignored).
Definition World.cpp:509
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:660
float getRayHitY() const
Definition World.h:351
std::string getEndContactFixtureATag(int index) const
Definition World.cpp:676
int getBeginTriggerSensorBodyId(int index) const
Definition World.cpp:691
float getImpactPointX(int index) const
Definition World.cpp:731
void drawDebug(graphics::Graphics *gfx)
Optional: draw fixture AABBs via Graphics::drawSolidRect.
int getQueryBodyId(int index) const
Definition World.cpp:845
int getQueryCount() const
Definition World.h:362
int getEndContactBodyBId(int index) const
Definition World.cpp:672
int getBeginContactBodyBId(int index) const
Definition World.cpp:656
std::string getEndTriggerSensorFixtureTag(int index) const
Definition World.cpp:709
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:296
int getEndTriggerVisitorBodyId(int index) const
Definition World.cpp:706
void setGravity(float gx, float gy)
Sets the world gravity vector in pixels/s^2.
Definition World.cpp:447
int getEndContactBodyAId(int index) const
Definition World.cpp:668
int getImpactCount() const
Definition World.h:389
float getGravityX() const
Definition World.cpp:452
float getRayHitFraction() const
Fraction along the segment [0,1] of the closest hit.
Definition World.h:355
float getRayHitNormalY() const
Definition World.h:353
bool hasRayHit() const
Definition World.h:348
Joint2D * newRevoluteJoint(Body *bodyA, Body *bodyB, float anchorX, float anchorY, bool collideConnected=false)
Creates a revolute hinge at a shared pixel-space anchor.
std::string getBeginTriggerSensorFixtureTag(int index) const
Definition World.cpp:697
float getImpactNormalX(int index) const
Definition World.cpp:739
float getImpactRelativeNormalSpeed(int index) const
Definition World.cpp:747
Body * newBody(const std::string &bodyType, float x, float y)
Creates a body in pixel-space units.
Definition World.cpp:478
std::string getBeginTriggerVisitorFixtureTag(int index) const
Definition World.cpp:700
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:652
std::string getEndTriggerVisitorFixtureTag(int index) const
Definition World.cpp:712
int getImpactBodyAId(int index) const
Definition World.cpp:715
int getBeginContactCount() const
Definition World.h:365
int getImpactBodyBId(int index) const
Definition World.cpp:719
float getRayHitNormalX() const
Definition World.h:352
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:370
int getBeginTriggerVisitorBodyId(int index) const
Definition World.cpp:694
float getImpactNormalImpulse(int index) const
Definition World.cpp:751
std::string getEndContactFixtureBTag(int index) const
Definition World.cpp:680
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:769
float getImpactTangentImpulse(int index) const
Definition World.cpp:755
float getGravityY() const
Definition World.cpp:457
std::string getBeginContactFixtureBTag(int index) const
Definition World.cpp:664
void updateFull(float dt, int velocityIterations, int positionIterations)
Steps with explicit iteration counts.
Definition World.cpp:396
void clearContactEvents()
Clears collected begin/end contact and impact event buffers.
Definition World.cpp:760
std::string getImpactFixtureATag(int index) const
Definition World.cpp:723
std::string getImpactFixtureBTag(int index) const
Definition World.cpp:727
float getMeter() const
Definition World.h:183
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:735
Mechanism2D * newShaft(Body *support, Body *rotor, float anchorX, float anchorY, bool collideConnected=false)
Builds a shaft (support↔rotor revolute) with optional drive motor helpers.
const Value * field(const Value::Object &object, std::string_view name)
Borrow an optional field only during the current synchronous codec call. @ownership Object owns the r...
Optional physics backend for vehicle mobility and body attach.
Definition Climbing.h:36
Result< DistanceField3D > distanceFieldFromSdfField3DBlob(const SdfField3DBlob &blob)
Build a DistanceField3D from a portable VertexGrid blob. @cost Allocates the destination grid and cop...
void exposeCoupling3DBindings(ssq::Table &table)
Register owning transmission Result factories; table is borrowed on the VM owner thread during this c...
ssq::Table projectSweepContactImpulse(World3D *world, const ssq::Object &event, PhysicsVector3D impulse, PhysicsVector3D point)
Project an explicit contact impulse through the canonical script Result boundary.
Result< void > beginTerrainLoadGravity(TerrainLoadGravityState *state, Body3D *body, bool terrainFound)
Begin monitoring a body when a containing terrain scene exists.
void exposeForceBindings(ssq::Table &table)
Register force model value classes and Result-projected functions. @ownership Table is borrowed for r...
void exposeJoint2DBindings(ssq::Table &table)
Register owning Joint2D Result factories; borrows table during this call on the VM owner thread only.
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.
Result< SdfField3DBlob > sdfField3DBlobFromDistanceField(const DistanceField3D &field)
Copy a DistanceField3D into the portable VertexGrid blob. @cost Copies every distance sample once.
std::unordered_map< std::string, SkillDefinition > & table()
Definition Skill.cpp:73
ssq::Table projectStatusResult(HSQUIRRELVM vm, const Status &status)
Project a checked native status that carries no payload.
ssq::Table projectResult(HSQUIRRELVM vm, Result< void > &&result)
Consume and project a void native Result using the common schema.
Result< Value > valueFromSquirrel(HSQUIRRELVM vm, SQInteger index, const SquirrelValueOptions &options)
Convert one Squirrel value into the canonical owning Value tree.
Result< Value > encodeSdfField3DBlob(const SdfField3DBlob &blob)
Encode a validated SDF blob to a Value object. @cost Copies the distance sample buffer into the Value...
Result< SdfField3DBlob > decodeSdfField3DBlob(const Value &value)
Decode a Value object into an owning SDF blob. @cost Allocates and copies the distance sample buffer ...