Godot Nature of Code  1.2.0
Nature of Code implemented in Godot Engine
Public Member Functions | Public Attributes | List of all members
VerletPhysics.VerletCluster Class Reference

Simple verlet cluster. More...

Public Member Functions

 VerletCluster (VerletWorld world, Vector2 centerPosition, int pointCount, float diameter, float gravityScale=1, float tearSensitivityFactor=-1, float stiffness=0.1f, bool drawPoints=true, float pointRadius=10f)
 Create a verlet cluster. More...
 

Public Attributes

List< VerletPointPoints
 Cluster points More...
 

Detailed Description

Simple verlet cluster.

Definition at line 9 of file VerletCluster.cs.

Constructor & Destructor Documentation

◆ VerletCluster()

VerletPhysics.VerletCluster.VerletCluster ( VerletWorld  world,
Vector2  centerPosition,
int  pointCount,
float  diameter,
float  gravityScale = 1,
float  tearSensitivityFactor = -1,
float  stiffness = 0.1f,
bool  drawPoints = true,
float  pointRadius = 10f 
)
inline

Create a verlet cluster.

Parameters
worldVerlet world
centerPositionCenter position
pointCountPoint count
diameterCluster diameter
gravityScaleGravity scale
tearSensitivityFactorDistance factor required to break the cloth. Use -1 to create an unbreakable cloth.
stiffnessStiffness of the cloth
drawPointsDraw points
pointRadiusVerlet point radius

Definition at line 26 of file VerletCluster.cs.

27  {
28  Points = new List<VerletPoint>();
29 
30  for (int i = 0; i < pointCount; ++i)
31  {
32  var position = centerPosition + new Vector2((float)GD.RandRange(-1, 1), (float)GD.RandRange(-1, 1));
33  var point = world.CreatePoint();
34  point.GravityScale = gravityScale;
35  point.Radius = pointRadius;
36  point.Visible = drawPoints;
37  point.MoveToPosition(position);
38  Points.Add(point);
39  }
40 
41  for (int i = 0; i < Points.Count - 1; ++i)
42  {
43  for (int j = i + 1; j < Points.Count; ++j)
44  {
45  var a = Points[i];
46  var b = Points[j];
47 
48  var link = world.CreateLink(a, b);
49  link.RestingDistance = diameter;
50  link.TearSensitivity = diameter * tearSensitivityFactor;
51  link.Stiffness = stiffness;
52  }
53  }
54  }
List< VerletPoint > Points
Cluster points

Member Data Documentation

◆ Points

List<VerletPoint> VerletPhysics.VerletCluster.Points

Cluster points

Definition at line 12 of file VerletCluster.cs.


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