Current project

Soft sphere

Arguments are center x/y/z, radius, segments (default 16) and optional construction settings. The sphere is a closed surface shell rather than a tetrahedral solid. Pressure and stiffness must be tuned together for size and mass; excessive pressure in a soft shell can overinflate it.

Example#

GML
ball = jolt_soft_body_create_sphere(0, 0, 3, 0.5, 24);
if (!is_undefined(ball)) {
    ball.set_mass(2);
    ball.set_stiffness(0.6);
    ball.set_pressure(100);
    ball.set_renderer(o_control_bbmod_renderer.renderer);
}

Usage and limits#

Set mass, stiffness, pressure, damping, friction, gravity factor, collision thickness and layer on the created object. Use spatial attachments for anchors and set_grab_enabled(true) for Carry. Creation returns undefined on error; check before calling methods. Register BBMOD rendering once and destroy the object in Clean Up.

API reference#

Public function and method signatures. Call methods on the returned instance; parameters with defaults are optional.

Function / methodSignature
jolt_soft_body_create_spherejolt_soft_body_create_sphere(x,y,z,radius,segments=16,settings=undefined)
JoltBBMODSphere.add_forceJoltBBMODSphere.add_force(x,y,z)
JoltBBMODSphere.destroyJoltBBMODSphere.destroy()
JoltBBMODSphere.drawJoltBBMODSphere.draw()
JoltBBMODSphere.get_collision_thicknessJoltBBMODSphere.get_collision_thickness()
JoltBBMODSphere.get_dampingJoltBBMODSphere.get_damping()
JoltBBMODSphere.get_frictionJoltBBMODSphere.get_friction()
JoltBBMODSphere.get_gravity_factorJoltBBMODSphere.get_gravity_factor()
JoltBBMODSphere.get_layerJoltBBMODSphere.get_layer()
JoltBBMODSphere.get_massJoltBBMODSphere.get_mass()
JoltBBMODSphere.get_native_handleJoltBBMODSphere.get_native_handle()
JoltBBMODSphere.get_positionJoltBBMODSphere.get_position()
JoltBBMODSphere.get_pressureJoltBBMODSphere.get_pressure()
JoltBBMODSphere.get_stretchJoltBBMODSphere.get_stretch()
JoltBBMODSphere.get_vertex_positionJoltBBMODSphere.get_vertex_position(index)
JoltBBMODSphere.get_volumeJoltBBMODSphere.get_volume()
JoltBBMODSphere.is_validJoltBBMODSphere.is_valid()
JoltBBMODSphere.renderJoltBBMODSphere.render()
JoltBBMODSphere.set_collision_thicknessJoltBBMODSphere.set_collision_thickness(v)
JoltBBMODSphere.set_dampingJoltBBMODSphere.set_damping(v)
JoltBBMODSphere.set_debugJoltBBMODSphere.set_debug(v)
JoltBBMODSphere.set_frictionJoltBBMODSphere.set_friction(v)
JoltBBMODSphere.set_gravity_factorJoltBBMODSphere.set_gravity_factor(v)
JoltBBMODSphere.set_layerJoltBBMODSphere.set_layer(layer)
JoltBBMODSphere.set_massJoltBBMODSphere.set_mass(v)
JoltBBMODSphere.set_materialJoltBBMODSphere.set_material(material)
JoltBBMODSphere.set_pressureJoltBBMODSphere.set_pressure(v)
JoltBBMODSphere.set_rendererJoltBBMODSphere.set_renderer(renderer)
JoltBBMODSphere.set_stretchJoltBBMODSphere.set_stretch(v)
JoltBBMODSphere.set_visibleJoltBBMODSphere.set_visible(value)
JoltBBMODSphere.update_meshJoltBBMODSphere.update_mesh(force=false)

Verified operation contracts#

These contracts distinguish units, return values, errors and lifetime according to the current implementation. Check results: false, 0 and undefined can mean different things for different methods.

Symbol / ownerSignatureOperation contract
jolt_soft_body_create_spherejolt_soft_body_create_sphere(x,y,z,radius,segments=16,settings=undefined)Returns JoltBBMODSphere or undefined in a running world. Radius .05..100 m; integer segments 8..64, default 16. This selects geodesic subdivision, not an exact particle count: 10*4^ceil(log2(segments/4))+2. Options mass=2, stiffness=.8, pressure=1000, damping=.1, friction=.5, gravity_factor=1, collision_thickness=.02, default layer. Thickness cannot exceed radius.
JoltBBMODSphere.add_forceJoltBBMODSphere.add_force(x,y,z)Finite world force components x/y/z in N; Boolean. Submits total force to the native soft body, not a local particle selection. Use jolt_soft_body_force for a local effect.
JoltBBMODSphere.destroyJoltBBMODSphere.destroy()Boolean, repeatedly true after successful destruction. Removes physics first, then renderer registration, owned meshes/materials, attachments, wind and force helpers. Borrowed materials and host bodies are not destroyed.
JoltBBMODSphere.drawJoltBBMODSphere.draw()Renders current deformed geometry if live and visible; no return value. draw aliases render. Do not additionally call these manually when registered with a renderer.
JoltBBMODSphere.get_collision_thicknessJoltBBMODSphere.get_collision_thickness()Current particle radius in m; undefined for an invalid wrapper, inspect native errors separately.
JoltBBMODSphere.get_dampingJoltBBMODSphere.get_damping()Linear damping: current numeric value in 1/s. Failure: undefined (invalid wrapper); inspect native errors separately; an invalid object is not a zero measurement.
JoltBBMODSphere.get_frictionJoltBBMODSphere.get_friction()Friction coefficient: current numeric value in dimensionless units. Failure: undefined (invalid wrapper); inspect native errors separately; an invalid object is not a zero measurement.
JoltBBMODSphere.get_gravity_factorJoltBBMODSphere.get_gravity_factor()Gravity multiplier: current numeric value in dimensionless units. Failure: undefined (invalid wrapper); inspect native errors separately; an invalid object is not a zero measurement.
JoltBBMODSphere.get_layerJoltBBMODSphere.get_layer()Returns a numeric layer handle, not a JoltLayer; undefined for an invalid wrapper.
JoltBBMODSphere.get_massJoltBBMODSphere.get_mass()Total mass: current numeric value in kg. Failure: undefined; an invalid object is not a zero measurement.
JoltBBMODSphere.get_native_handleJoltBBMODSphere.get_native_handle()Valid soft-body handle, otherwise 0. Not a JoltBody handle for rigid-body methods.
JoltBBMODSphere.get_positionJoltBBMODSphere.get_position()World mean particle position {x, y, z} in m, not a rigid transform; undefined for an invalid wrapper.
JoltBBMODSphere.get_pressureJoltBBMODSphere.get_pressure()Internal pressure of a closed surface: current numeric value in N/m². Failure: undefined; an invalid object is not a zero measurement. Open model cloth has no pressure; nonzero settings are rejected.
JoltBBMODSphere.get_stretchJoltBBMODSphere.get_stretch()Stretch stiffness: current numeric value in dimensionless units. Failure: undefined; an invalid object is not a zero measurement.
JoltBBMODSphere.get_vertex_positionJoltBBMODSphere.get_vertex_position(index)Integer index 0 ≤ index < vertex_count. Returns world {x, y, z} in m, undefined for an invalid index/wrapper.
JoltBBMODSphere.get_volumeJoltBBMODSphere.get_volume()Volume in m³ from current deformation; open model cloth returns 0. undefined for invalid object or read failure.
JoltBBMODSphere.is_validJoltBBMODSphere.is_valid()Boolean based on the wrapper, handle and original managed world. Not a native existence query for every particle; do not mix raw destruction with managed ownership.
JoltBBMODSphere.renderJoltBBMODSphere.render()Renders current deformed geometry if live and visible; no return value. draw aliases render. Do not additionally call these manually when registered with a renderer.
JoltBBMODSphere.set_collision_thicknessJoltBBMODSphere.set_collision_thickness(v)Particle collision radius in m, finite ≥0. Upper bound: Sphere radius, half the smallest Box dimension, half the shortest model edge. Boolean; default 0.02 Sphere/Box, model 0.01 or a smaller edge-adjusted value when omitted from options.
JoltBBMODSphere.set_dampingJoltBBMODSphere.set_damping(v)Linear damping: finite number 0..1000 1/s; default 0.1 Sphere, 0.5 Box, 0.2 closed model / 0.1 model cloth. Returns true on acceptance, false for an invalid input or object. Updates the live object.
JoltBBMODSphere.set_debugJoltBBMODSphere.set_debug(v)Enables diagnostic drawing, default false; returns true. Does not change physics or object lifetime.
JoltBBMODSphere.set_frictionJoltBBMODSphere.set_friction(v)Friction coefficient: finite number 0..1000 ; default 0.5. Returns true on acceptance, false for an invalid input or object. Updates the live object.
JoltBBMODSphere.set_gravity_factorJoltBBMODSphere.set_gravity_factor(v)Gravity multiplier: finite number 0..1000 ; default 1. Returns true on acceptance, false for an invalid input or object. Updates the live object.
JoltBBMODSphere.set_layerJoltBBMODSphere.set_layer(layer)JoltLayer or positive integer layer handle; the layer must exist in this world. Boolean. Does not modify the layer collision matrix.
JoltBBMODSphere.set_massJoltBBMODSphere.set_mass(v)Total mass: finite number 0.01..1000000 kg; default 2 (Sphere/Box), 2 closed model / 1 model cloth. Returns true on acceptance, false for an invalid input or object. Updates the live object.
JoltBBMODSphere.set_materialJoltBBMODSphere.set_material(material)BBMOD_BaseMaterial or undefined for an automatic owned two-sided material. Boolean; user material is borrowed and not destroyed, a previous owned material is released.
JoltBBMODSphere.set_pressureJoltBBMODSphere.set_pressure(v)Internal pressure of a closed surface: finite number 0..1000000 N/m²; default 1000 Sphere, 50 closed model, 0 open model cloth. Returns true on acceptance, false for an invalid input or object. Updates the live object. Open model cloth has no pressure; nonzero settings are rejected.
JoltBBMODSphere.set_rendererJoltBBMODSphere.set_renderer(renderer)Live BBMOD_BaseRenderer or undefined to detach. Boolean; registers/unregisters this same object, do not additionally register it by hand. Requires a live soft body.
JoltBBMODSphere.set_stretchJoltBBMODSphere.set_stretch(v)Stretch stiffness: finite number 0..1 ; default 0.8 Sphere/closed model, 0.3 Box, 0.9 model cloth. Returns true on acceptance, false for an invalid input or object. Updates the live object.
JoltBBMODSphere.set_visibleJoltBBMODSphere.set_visible(value)Input coerced to Boolean, default true. Returns Boolean success. Hides rendering without disabling physics.
JoltBBMODSphere.update_meshJoltBBMODSphere.update_mesh(force=false)Boolean success; force=false uses the physics revision cache. force=true forces an update even after manual native stepping. Positions are already world-space; do not apply the body transform again.