Paths

Smooth Paths

Builds a cubic Hermite curve and provides distance-aware sampling utilities.

build_smooth() generates missing tangents, constructs the native PathConstraintPathHermite, transports a stable normal along the curve, applies each point's roll, and builds an approximate arc-length table.

Syntax#

Syntax
track.build_smooth(smoothness=1.0);

Requirements#

PropertyRequirement
smoothnessFinite, greater than 0, and at most 4.
open pathAt least 2 control points.
looping pathAt least 3 control points.
segmentsConsecutive positions must differ.

Automatic tangent rule#

  • Interior open-path and all loop tangents use 0.5 × smoothness × (next − previous).
  • Open-path endpoints use smoothness times their adjacent segment.
  • Tangents added with add_point_tangent() are preserved.

Sampling by arc length#

GML
var midpoint = track.get_position(0.5);
var direction = track.get_direction(0.5);

var distance = track.get_length() * 0.25;
var position = track.get_position_at_distance(distance);
var tangent = track.get_direction_at_distance(distance);

Public fractions represent normalized approximate arc length, not the raw per-segment Hermite parameter. Fraction 0.5 is therefore the physical midpoint of the path.

Frames and spatial queries#

GML
var euler = track.get_rotation(0.5);
var quaternion = track.get_rotation_quaternion(0.5);
var nearest = track.get_closest_point(x, y, z);
var bounds = track.get_bounds();
Closest-point fieldMeaning
positionNearest sampled Hermite position.
distanceWorld-space distance from the query point.
fractionNormalized arc-length fraction.
path_distanceDistance along the path.
directionPath tangent at the closest position.

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
JoltPath.build_smoothJoltPath.build_smooth(smoothness = 1.0)Boolean; smoothness(0, 4] default 1, at least2 open/3 loop points. Computes implicit tangents and builds a new native resource. An invalid build cannot be sampled.
JoltPath.get_boundsJoltPath.get_bounds()After build:length m(error0), copied bounds min_x/y/z, max_x/y/z(error undefined) in path coordinates.
JoltPath.get_closest_pointJoltPath.get_closest_point(x, y, z)XYZ in path coordinates, after build; snapshot {position, distance, fraction, path_distance, direction}. Distance from query and path_distance along curve in m; undefined on error.
JoltPath.get_directionJoltPath.get_direction(fraction)Requires current build; fraction0..1 or finite distance m. Returns {x, y, z} position m / unit tangent in path coordinates, undefined when rejected.
JoltPath.get_direction_at_distanceJoltPath.get_direction_at_distance(distance)Requires current build; fraction0..1 or finite distance m. Returns {x, y, z} position m / unit tangent in path coordinates, undefined when rejected.
JoltPath.get_lengthJoltPath.get_length()After build:length m(error0), copied bounds min_x/y/z, max_x/y/z(error undefined) in path coordinates.
JoltPath.get_positionJoltPath.get_position(fraction)Requires current build; fraction0..1 or finite distance m. Returns {x, y, z} position m / unit tangent in path coordinates, undefined when rejected.
JoltPath.get_position_at_distanceJoltPath.get_position_at_distance(distance)Requires current build; fraction0..1 or finite distance m. Returns {x, y, z} position m / unit tangent in path coordinates, undefined when rejected.
JoltPath.get_rotationJoltPath.get_rotation(fraction)Fraction0..1 after build; XYZW quaternion only from get_rotation_quaternion. Both get_rotation and get_rotation_euler return Euler XYZ°! undefined on error.
JoltPath.get_rotation_eulerJoltPath.get_rotation_euler(fraction)Fraction0..1 after build; XYZW quaternion only from get_rotation_quaternion. Both get_rotation and get_rotation_euler return Euler XYZ°! undefined on error.
JoltPath.get_rotation_quaternionJoltPath.get_rotation_quaternion(fraction)Fraction0..1 after build; XYZW quaternion only from get_rotation_quaternion. Both get_rotation and get_rotation_euler return Euler XYZ°! undefined on error.