Simple verlet world which handle simulation book-keeping.
More...
Inherits Node2D.
|
| VerletWorld () |
| Create a default verlet world. More...
|
|
VerletPoint | CreatePoint (Vector2? initialPosition=null, float? mass=null, float? gravityScale=null, float? radius=null, Color? color=null, bool? visible=null) |
| Create a verlet point. More...
|
|
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. More...
|
|
void | QueueLinkRemoval (VerletLink link) |
| Mark a link to be removed next frame. More...
|
|
void | AddBehavior (IBehavior behavior) |
| Add a new behavior. More...
|
|
void | RemoveBehavior (IBehavior behavior) |
| Remove an existing behavior. More...
|
|
Simple verlet world which handle simulation book-keeping.
Definition at line 9 of file VerletWorld.cs.
◆ VerletWorld()
VerletPhysics.VerletWorld.VerletWorld |
( |
| ) |
|
|
inline |
Create a default verlet world.
Definition at line 21 of file VerletWorld.cs.
23 points =
new List<VerletPoint>();
24 linksToRemove =
new List<VerletLink>();
25 behaviors =
new List<IBehavior>();
◆ AddBehavior()
void VerletPhysics.VerletWorld.AddBehavior |
( |
IBehavior |
behavior | ) |
|
|
inline |
Add a new behavior.
- Parameters
-
Definition at line 123 of file VerletWorld.cs.
125 behaviors.Add(behavior);
◆ CreateLink()
VerletLink VerletPhysics.VerletWorld.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 |
|
) |
| |
|
inline |
Create a verlet link.
- Parameters
-
a | First verlet point |
b | First verlet point |
restingDistance | Resting distance |
minimalDistance | Minimal link distance. Use -1 to disable. |
maximalDistance | Maximal link distance. Use -1 to disable. |
tearSensitivity | Distance required to break the link. Use -1 to create an unbreakable link. |
tearSensitivityFactor | Distance factor required to break the link. Use -1 to create an unbreakable link. |
stiffness | Stiffness of the link |
width | Width of the link |
color | Link color |
visible | Show link |
- Returns
- Verlet link
Definition at line 73 of file VerletWorld.cs.
86 var link =
new VerletLink(
this, a, b);
90 link.Visible = visible ?? link.Visible;
91 link.RestingDistance = restingDistance ?? link.RestingDistance;
92 link.MinimalDistance = minimalDistance ?? link.MinimalDistance;
93 link.MaximalDistance = maximalDistance ?? link.MaximalDistance;
94 link.TearSensitivity = tearSensitivity ?? link.TearSensitivity;
95 link.Stiffness = stiffness ?? link.Stiffness;
96 link.Modulate = color ?? link.Modulate;
97 link.Width = width ?? link.Width;
99 if (tearSensitivityFactor.HasValue)
101 link.TearSensitivity = link.RestingDistance * tearSensitivityFactor.Value;
◆ CreatePoint()
VerletPoint VerletPhysics.VerletWorld.CreatePoint |
( |
Vector2? |
initialPosition = null , |
|
|
float? |
mass = null , |
|
|
float? |
gravityScale = null , |
|
|
float? |
radius = null , |
|
|
Color? |
color = null , |
|
|
bool? |
visible = null |
|
) |
| |
|
inline |
Create a verlet point.
- Parameters
-
initialPosition | Initial position |
mass | Mass |
gravityScale | Gravity scale |
radius | Radius |
color | Color |
visible | Show point |
- Returns
- Verlet point
Definition at line 38 of file VerletWorld.cs.
40 var point =
new VerletPoint(
this);
44 point.Mass = mass ?? point.Mass;
45 point.GravityScale = gravityScale ?? point.GravityScale;
46 point.Radius = radius ?? point.Radius;
47 point.Visible = visible ?? point.Visible;
48 point.Modulate = color ?? point.Modulate;
50 if (initialPosition.HasValue)
52 point.MoveToPosition(initialPosition.Value);
◆ QueueLinkRemoval()
void VerletPhysics.VerletWorld.QueueLinkRemoval |
( |
VerletLink |
link | ) |
|
|
inline |
Mark a link to be removed next frame.
- Parameters
-
Definition at line 111 of file VerletWorld.cs.
113 if (!linksToRemove.Contains(link))
115 linksToRemove.Add(link);
◆ RemoveBehavior()
void VerletPhysics.VerletWorld.RemoveBehavior |
( |
IBehavior |
behavior | ) |
|
|
inline |
Remove an existing behavior.
- Parameters
-
Definition at line 132 of file VerletWorld.cs.
134 behaviors.Remove(behavior);
◆ ConstraintAccuracy
int VerletPhysics.VerletWorld.ConstraintAccuracy = 2 |
The documentation for this class was generated from the following file: