Simple verlet chain builder. Uses a PointConfiguratorFunc to configure VerletPoints on creation.  
 More...
|  | 
| delegate void | PointConfiguratorFunc (VerletPoint point) | 
|  | Point configuration function definition  More... 
 | 
|  | 
|  | VerletChainBuilder (VerletWorld world, bool pinFirst=true, bool pinLast=false, bool drawIntermediatePoints=false) | 
|  | Create a verlet chain builder.  More... 
 | 
|  | 
| VerletChainBuilder | AddPointAtPosition (float x, float y, PointConfiguratorFunc configurator=null) | 
|  | Add chain point at a specific position.  More... 
 | 
|  | 
| VerletChainBuilder | AddPointAtPosition (Vector2 position, PointConfiguratorFunc configurator=null) | 
|  | Add chain point at a specific position.  More... 
 | 
|  | 
| VerletChainBuilder | AddPointWithOffset (float x, float y, PointConfiguratorFunc configurator=null) | 
|  | Add chain point with offset from previous point position. If not already set, the first point will be offset from (0, 0).  More... 
 | 
|  | 
| VerletChainBuilder | AddPointWithOffset (Vector2 offset, PointConfiguratorFunc configurator=null) | 
|  | Add chain point with offset from previous point position. If not already set, the first point will be offset from (0, 0).  More... 
 | 
|  | 
| VerletChainBuilder | AddPointsWithOffset (int pointCount, float x, float y, PointConfiguratorFunc configurator=null) | 
|  | Add multiple chain points with offset from previous points positions. If not already set, the first point will be offset from (0, 0).  More... 
 | 
|  | 
| VerletChainBuilder | AddPointsWithOffset (int pointCount, Vector2 offset, PointConfiguratorFunc configurator=null) | 
|  | Add multiple chain points with offset from previous points positions. If not already set, the first point will be offset from (0, 0).  More... 
 | 
|  | 
| void | Build (float restingDistance=50, float tearSensitivity=100, float stiffness=1) | 
|  | Build the verlet chain.  More... 
 | 
|  | 
Simple verlet chain builder. Uses a PointConfiguratorFunc to configure VerletPoints on creation. 
Definition at line 14 of file VerletChainBuilder.cs.
◆ VerletChainBuilder()
  
  | 
        
          | VerletPhysics.VerletChainBuilder.VerletChainBuilder | ( | VerletWorld | world, |  
          |  |  | bool | pinFirst = true, |  
          |  |  | bool | pinLast = false, |  
          |  |  | bool | drawIntermediatePoints = false |  
          |  | ) |  |  |  | inline | 
 
Create a verlet chain builder. 
- Parameters
- 
  
    | world | Verlet world |  | pinFirst | Pin first chain point |  | pinLast | Pin last chain point |  | drawIntermediatePoints | Draw chain intermediate points |  
 
Definition at line 32 of file VerletChainBuilder.cs.
   35             this.pinFirst = pinFirst;
 
   36             this.pinLast = pinLast;
 
   37             this.drawIntermediatePoints = drawIntermediatePoints;
 
   38             points = 
new List<VerletPoint>();
 
 
 
 
◆ AddPointAtPosition() [1/2]
Add chain point at a specific position. 
- Parameters
- 
  
    | x | X coordinate |  | y | Y coordinate |  | configurator | Point configurator |  
 
- Returns
- Builder
Definition at line 48 of file VerletChainBuilder.cs.
VerletChainBuilder AddPointAtPosition(float x, float y, PointConfiguratorFunc configurator=null)
Add chain point at a specific position.
 
 
 
◆ AddPointAtPosition() [2/2]
Add chain point at a specific position. 
- Parameters
- 
  
    | position | Position vector |  | configurator | Point configurator |  
 
- Returns
- Builder
Definition at line 59 of file VerletChainBuilder.cs.
   64             if (points.Count == 0 && pinFirst)
 
   66                 point.PinToCurrentPosition();
 
   68             else if (!drawIntermediatePoints)
 
   70                 point.Visible = 
false;
 
   73             configurator?.Invoke(point);
 
void MoveToPosition(Vector2 position)
Move point to position.
VerletPoint CreatePoint(Vector2? initialPosition=null, float? mass=null, float? gravityScale=null, float? radius=null, Color? color=null, bool? visible=null)
Create a verlet point.
 
 
 
◆ AddPointsWithOffset() [1/2]
Add multiple chain points with offset from previous points positions. If not already set, the first point will be offset from (0, 0). 
- Parameters
- 
  
    | pointCount | Point count |  | x | X offset |  | y | Y offset |  | configurator | Point configurator |  
 
- Returns
- Builder
Definition at line 118 of file VerletChainBuilder.cs.
VerletChainBuilder AddPointsWithOffset(int pointCount, float x, float y, PointConfiguratorFunc configurator=null)
Add multiple chain points with offset from previous points positions. If not already set,...
 
 
 
◆ AddPointsWithOffset() [2/2]
Add multiple chain points with offset from previous points positions. If not already set, the first point will be offset from (0, 0). 
- Parameters
- 
  
    | pointCount | Point count |  | offset | Offset vector |  | configurator | Point configurator |  
 
- Returns
- Builder
Definition at line 131 of file VerletChainBuilder.cs.
  134             for (
int i = 0; i < pointCount; ++i)
 
  136                 builder = builder.AddPointWithOffset(offset, configurator);
 
 
 
 
◆ AddPointWithOffset() [1/2]
Add chain point with offset from previous point position. If not already set, the first point will be offset from (0, 0). 
- Parameters
- 
  
    | x | X coordinate |  | y | Y coordinate |  | configurator | Point configurator |  
 
- Returns
- Builder
Definition at line 86 of file VerletChainBuilder.cs.
VerletChainBuilder AddPointWithOffset(float x, float y, PointConfiguratorFunc configurator=null)
Add chain point with offset from previous point position. If not already set, the first point will be...
 
 
 
◆ AddPointWithOffset() [2/2]
Add chain point with offset from previous point position. If not already set, the first point will be offset from (0, 0). 
- Parameters
- 
  
    | offset | Offset vector |  | configurator | Point configurator |  
 
- Returns
- Builder
Definition at line 98 of file VerletChainBuilder.cs.
  100             Vector2 prevPosition = Vector2.Zero;
 
  101             if (points.Count > 0)
 
  103                 prevPosition = points[^1].GlobalPosition;
 
 
 
 
◆ Build()
  
  | 
        
          | void VerletPhysics.VerletChainBuilder.Build | ( | float | restingDistance = 50, |  
          |  |  | float | tearSensitivity = 100, |  
          |  |  | float | stiffness = 1 |  
          |  | ) |  |  |  | inline | 
 
Build the verlet chain. 
- Parameters
- 
  
    | restingDistance | Resting distance |  | tearSensitivity | Distance required to break the chain. Use -1to create an unbreakable chain. |  | stiffness | Stiffness of the chain |  
 
Definition at line 147 of file VerletChainBuilder.cs.
  149             if (points.Count < 2)
 
  151                 GD.PrintErr(
"Bad points length for chain. Need to be >= 2");
 
  156             var lastPoint = points[^1];
 
  159                 lastPoint.PinToCurrentPosition();
 
  163             lastPoint.Visible = 
true;
 
  165             VerletPoint prevPoint = points[0];
 
  166             for (
int i = 1; i < points.Count; ++i)
 
  168                 var currPoint = points[i];
 
  170                 var link = world.
CreateLink(prevPoint, currPoint);
 
  172                 link.TearSensitivity = tearSensitivity;
 
  173                 link.Stiffness = stiffness;
 
  175                 prevPoint = currPoint;
 
float RestingDistance
Resting distance
VerletLink CreateLink(VerletPoint a, VerletPoint b, float? restingDistance=null, float? minimalDistance=null, float? maximalDistance=null, float? tearSensitivity=null, float? tearSensitivityFactor=null, float? stiffness=null, float? width=null, Color? color=null, bool? visible=null)
Create a verlet link.
 
 
 
◆ PointConfiguratorFunc()
      
        
          | delegate void VerletPhysics.VerletChainBuilder.PointConfiguratorFunc | ( | VerletPoint | point | ) |  | 
      
 
Point configuration function definition 
 
 
The documentation for this class was generated from the following file: