‹›
Current project

Volumetric soft box

Position is the center; width/depth/height are full X/Y/Z lengths in metres. Each grid cell has six tetrahedra. Default resolution 4 produces 125 particles and 384 tetrahedra. Resolution is fixed at creation. This type has volume stiffness, not a pressure setter.

Example#

GML
soft = jolt_soft_body_create_box(0, 0, 3, 2, 1, 1, {resolution:4});
if (!is_undefined(soft)) {
    soft.set_mass(2);
    soft.set_stiffness(0.3);
    soft.set_volume_stiffness(0.8);
    soft.set_damping(0.5);
    soft.set_renderer(o_control_bbmod_renderer.renderer);
}

Usage and limits#

Stiffness controls elastic edges; volume stiffness resists volume change. Both range 0..1. Zero means the softest finite compliance, not removal of all constraints; one does not make a rigid body. Higher resolution costs more simulation time. Attachments can include internal particles; Carry grips surface neighborhoods.

Use get_volume for current signed volume, get_position for mean particle position and get_vertex_position(index) for world particle coordinates. Rendering updates through BBMOD and the existing physics loop.

API reference#

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

Function / methodSignature
jolt_soft_body_create_boxjolt_soft_body_create_box(x,y,z,width,depth,height,settings=undefined)
JoltBBMODBox.add_forceJoltBBMODBox.add_force(x,y,z)
JoltBBMODBox.destroyJoltBBMODBox.destroy()
JoltBBMODBox.drawJoltBBMODBox.draw()
JoltBBMODBox.get_collision_thicknessJoltBBMODBox.get_collision_thickness()
JoltBBMODBox.get_dampingJoltBBMODBox.get_damping()
JoltBBMODBox.get_frictionJoltBBMODBox.get_friction()
JoltBBMODBox.get_gravity_factorJoltBBMODBox.get_gravity_factor()
JoltBBMODBox.get_layerJoltBBMODBox.get_layer()
JoltBBMODBox.get_massJoltBBMODBox.get_mass()
JoltBBMODBox.get_native_handleJoltBBMODBox.get_native_handle()
JoltBBMODBox.get_positionJoltBBMODBox.get_position()
JoltBBMODBox.get_stretchJoltBBMODBox.get_stretch()
JoltBBMODBox.get_vertex_positionJoltBBMODBox.get_vertex_position(index)
JoltBBMODBox.get_volumeJoltBBMODBox.get_volume()
JoltBBMODBox.get_volume_stiffnessJoltBBMODBox.get_volume_stiffness()
JoltBBMODBox.is_validJoltBBMODBox.is_valid()
JoltBBMODBox.renderJoltBBMODBox.render()
JoltBBMODBox.set_collision_thicknessJoltBBMODBox.set_collision_thickness(v)
JoltBBMODBox.set_dampingJoltBBMODBox.set_damping(v)
JoltBBMODBox.set_debugJoltBBMODBox.set_debug(v)
JoltBBMODBox.set_debug_internalJoltBBMODBox.set_debug_internal(v)
JoltBBMODBox.set_frictionJoltBBMODBox.set_friction(v)
JoltBBMODBox.set_gravity_factorJoltBBMODBox.set_gravity_factor(v)
JoltBBMODBox.set_layerJoltBBMODBox.set_layer(layer)
JoltBBMODBox.set_massJoltBBMODBox.set_mass(v)
JoltBBMODBox.set_materialJoltBBMODBox.set_material(material)
JoltBBMODBox.set_rendererJoltBBMODBox.set_renderer(renderer)
JoltBBMODBox.set_stretchJoltBBMODBox.set_stretch(v)
JoltBBMODBox.set_visibleJoltBBMODBox.set_visible(value)
JoltBBMODBox.set_volume_stiffnessJoltBBMODBox.set_volume_stiffness(v)
JoltBBMODBox.update_meshJoltBBMODBox.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_boxjolt_soft_body_create_box(x,y,z,width,depth,height,settings=undefined)Returns JoltBBMODBox or undefined in a running world. Full X/Y/Z dimensions .05..100 m. Options mass=2, stiffness=.3, volume_stiffness=.8, damping=.5, friction=.5, gravity_factor=1, collision_thickness=.02, resolution=4 (integer 1..10), rotation_x/y/z=0°, default layer. Particle count is (resolution+1)^3; thickness ≤ half the smallest dimension.
JoltBBMODBox.add_forceJoltBBMODBox.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.
JoltBBMODBox.destroyJoltBBMODBox.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.
JoltBBMODBox.drawJoltBBMODBox.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.
JoltBBMODBox.get_collision_thicknessJoltBBMODBox.get_collision_thickness()Current particle radius in m; undefined for an invalid wrapper, inspect native errors separately.
JoltBBMODBox.get_dampingJoltBBMODBox.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.
JoltBBMODBox.get_frictionJoltBBMODBox.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.
JoltBBMODBox.get_gravity_factorJoltBBMODBox.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.
JoltBBMODBox.get_layerJoltBBMODBox.get_layer()Returns a numeric layer handle, not a JoltLayer; undefined for an invalid wrapper.
JoltBBMODBox.get_massJoltBBMODBox.get_mass()Total mass: current numeric value in kg. Failure: undefined; an invalid object is not a zero measurement.
JoltBBMODBox.get_native_handleJoltBBMODBox.get_native_handle()Valid soft-body handle, otherwise 0. Not a JoltBody handle for rigid-body methods.
JoltBBMODBox.get_positionJoltBBMODBox.get_position()World mean particle position {x, y, z} in m, not a rigid transform; undefined for an invalid wrapper.
JoltBBMODBox.get_stretchJoltBBMODBox.get_stretch()Stretch stiffness: current numeric value in dimensionless units. Failure: undefined; an invalid object is not a zero measurement.
JoltBBMODBox.get_vertex_positionJoltBBMODBox.get_vertex_position(index)Integer index 0 ≤ index < vertex_count. Returns world {x, y, z} in m, undefined for an invalid index/wrapper.
JoltBBMODBox.get_volumeJoltBBMODBox.get_volume()Volume in m³ from current deformation; open model cloth returns 0. undefined for invalid object or read failure.
JoltBBMODBox.get_volume_stiffnessJoltBBMODBox.get_volume_stiffness()Volume stiffness: current numeric value in dimensionless units. Failure: undefined; an invalid object is not a zero measurement.
JoltBBMODBox.is_validJoltBBMODBox.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.
JoltBBMODBox.renderJoltBBMODBox.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.
JoltBBMODBox.set_collision_thicknessJoltBBMODBox.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.
JoltBBMODBox.set_dampingJoltBBMODBox.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.
JoltBBMODBox.set_debugJoltBBMODBox.set_debug(v)Enables diagnostic drawing, default false; returns true. Does not change physics or object lifetime.
JoltBBMODBox.set_debug_internalJoltBBMODBox.set_debug_internal(v)Boolean coercion; enabling also enables ordinary debug. Returns true, without changing physics.
JoltBBMODBox.set_frictionJoltBBMODBox.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.
JoltBBMODBox.set_gravity_factorJoltBBMODBox.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.
JoltBBMODBox.set_layerJoltBBMODBox.set_layer(layer)JoltLayer or positive integer layer handle; the layer must exist in this world. Boolean. Does not modify the layer collision matrix.
JoltBBMODBox.set_massJoltBBMODBox.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.
JoltBBMODBox.set_materialJoltBBMODBox.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.
JoltBBMODBox.set_rendererJoltBBMODBox.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.
JoltBBMODBox.set_stretchJoltBBMODBox.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.
JoltBBMODBox.set_visibleJoltBBMODBox.set_visible(value)Input coerced to Boolean, default true. Returns Boolean success. Hides rendering without disabling physics.
JoltBBMODBox.set_volume_stiffnessJoltBBMODBox.set_volume_stiffness(v)Volume stiffness: finite number 0..1 ; default 0.8. Returns true on acceptance, false for an invalid input or object. Updates the live object.
JoltBBMODBox.update_meshJoltBBMODBox.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.