Donner 0.8.0-pre
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
donner::editor::RopeSimulation Class Reference

Small fixed-endpoint Verlet rope simulation used by source reference connectors. More...

#include "donner/editor/RopeSimulation.h"

Public Member Functions

 RopeSimulation ()=default
 Construct an empty rope simulation.
void reset (std::span< const Vector2d > route, const RopeSimulationOptions &options)
 Reset this rope by sampling route into evenly spaced simulated particles.
void resetCatenary (const Vector2d &start, const Vector2d &end, const RopeSimulationOptions &options)
 Reset this rope to a catenary between fixed endpoints.
void applyImpulse (const Vector2d &impulse)
 Add an instantaneous velocity impulse to interior rope particles.
void applyBottomImpulse (const Vector2d &impulse, double normalizedWidth)
 Add a localized velocity impulse centered on the lowest interior particle.
void update (const Vector2d &start, const Vector2d &end, double deltaTimeSeconds, double scrollDeltaY, double timeSeconds, std::uint32_t phaseSeed, bool frozen, const RopeSimulationOptions &options)
 Advance the rope by one frame.
std::span< const Vector2dpoints () const
 Return the simulated particle positions.
bool empty () const
 Return true when this rope has no particles.
bool needsAnimation () const
 Return true when this rope still needs timed animation frames.
Path toPath (const RopeSimulationOptions &options) const
 Convert the current rope body into a Bézier path.
Vector2d endTangent () const
 Return the final segment tangent for orienting an arrowhead.

Detailed Description

Small fixed-endpoint Verlet rope simulation used by source reference connectors.

Member Function Documentation

◆ applyBottomImpulse()

void donner::editor::RopeSimulation::applyBottomImpulse ( const Vector2d & impulse,
double normalizedWidth )

Add a localized velocity impulse centered on the lowest interior particle.

Parameters
impulseScreen-space velocity displacement at the catenary bottom.
normalizedWidthSine-normalized falloff width in [0, 1].

◆ applyImpulse()

void donner::editor::RopeSimulation::applyImpulse ( const Vector2d & impulse)

Add an instantaneous velocity impulse to interior rope particles.

Parameters
impulseScreen-space velocity displacement applied with a sine envelope.

◆ reset()

void donner::editor::RopeSimulation::reset ( std::span< const Vector2d > route,
const RopeSimulationOptions & options )

Reset this rope by sampling route into evenly spaced simulated particles.

Parameters
routePolyline route from fixed start to fixed end.
optionsSimulation options controlling segment count and smoothing.

◆ resetCatenary()

void donner::editor::RopeSimulation::resetCatenary ( const Vector2d & start,
const Vector2d & end,
const RopeSimulationOptions & options )

Reset this rope to a catenary between fixed endpoints.

The resulting rest lengths come from the sampled catenary, so gravity and distance constraints settle toward the same hanging-curve family instead of a pre-routed polyline. The rope starts asleep with zero velocity; callers may wake it with applyBottomImpulse or endpoint motion.

Parameters
startFixed rope start point in screen coordinates.
endFixed rope end point in screen coordinates.
optionsSimulation options controlling slack and segment count.

◆ update()

void donner::editor::RopeSimulation::update ( const Vector2d & start,
const Vector2d & end,
double deltaTimeSeconds,
double scrollDeltaY,
double timeSeconds,
std::uint32_t phaseSeed,
bool frozen,
const RopeSimulationOptions & options )

Advance the rope by one frame.

Parameters
startFixed rope start point in screen coordinates.
endFixed rope end point in screen coordinates.
deltaTimeSecondsFrame delta time in seconds.
scrollDeltaYSource-pane vertical scroll delta since the previous frame.
timeSecondsMonotonic UI time in seconds, used for idle sway phase.
phaseSeedStable per-rope seed used to desynchronize idle sway.
frozenIf true, skip integration and keep the rope body stable for interaction.
optionsSimulation options.

The documentation for this class was generated from the following file: