### Check .NET SDK version Source: https://jitterphysics.com/docs/tutorials/boxes/project-setup.html Verifies that the .NET SDK is installed and accessible from the command line. Run this after installing the .NET 10 SDK to confirm the setup. ```bash dotnet --version ``` -------------------------------- ### Start Field Source: https://jitterphysics.com/api/Jitter2.Parallelization.Parallel.Batch.html The inclusive start index of the batch. ```APIDOC ## Start Field ### Description The inclusive start index of the batch. ### Field `public readonly int Start` ### Field Value - **int** - The inclusive start index. ``` -------------------------------- ### Batch(int start, int end) Source: https://jitterphysics.com/api/Jitter2.Parallelization.Parallel.Batch.html Initializes a new instance of the Batch struct with the specified start and end indices. ```APIDOC ## Batch(int start, int end) ### Description Initializes a new instance of the Batch struct with the specified start and end indices. ### Constructor `public Batch(int start, int end)` ### Parameters - **start** (int) - The inclusive start index of the batch. - **end** (int) - The exclusive end index of the batch. ``` -------------------------------- ### Run the console application Source: https://jitterphysics.com/docs/tutorials/boxes/project-setup.html Runs the console application. After setup, executing this command should display 'Hello, World!' in the console. ```bash dotnet run ``` -------------------------------- ### Overlap check example using bounding box query and narrowphase test Source: https://jitterphysics.com/docs/documentation/dynamictree.html Static method that returns all RigidBodyShapes overlapping a sphere. It first queries the DynamicTree with a bounding box to get candidates, then runs an exact narrowphase overlap test against each candidate. This pattern avoids additional broadphase API surface. ```csharp // Returns all RigidBodyShapes overlapping a sphere at 'center' with 'radius'. static IEnumerable OverlapSphere(World world, JVector center, float radius) { var queryBox = new JBoundingBox( center - new JVector(radius), center + new JVector(radius)); var candidates = new List(); world.DynamicTree.Query(candidates, queryBox); var querySphere = SupportPrimitives.CreateSphere(radius); foreach (var proxy in candidates) { if (proxy is not RigidBodyShape shape) continue; ref var data = ref shape.RigidBody.Data; bool hit = NarrowPhase.Overlap( querySphere, shape, JQuaternion.Identity, data.Orientation, center, data.Position); if (hit) yield return shape; } } ``` -------------------------------- ### Create console app and add Raylib-cs and Jitter2 packages Source: https://jitterphysics.com/docs/tutorials/boxes/project-setup.html Creates a new console application and adds the Raylib-cs (version 6.1.1) and Jitter2 NuGet packages. These commands are run sequentially in the BoxDrop directory. ```bash dotnet new console ``` ```bash dotnet add package Raylib-cs --version 6.1.1 ``` ```bash dotnet add package Jitter2 ``` -------------------------------- ### Initialize Method (3 parameters) Source: https://jitterphysics.com/api/Jitter2.Dynamics.Constraints.PointOnLine.html Initializes the constraint from world-space parameters. ```APIDOC ## Method: Initialize (3 parameters) ### Description Initializes the constraint from world-space parameters. ### Signature ```csharp public void Initialize(JVector axis, JVector anchor1, JVector anchor2) ``` ### Parameters - **axis** (JVector) - The line axis in world space, fixed in the reference frame of body 1. - **anchor1** (JVector) - Anchor point on body 1 defining the line origin in world space. - **anchor2** (JVector) - Anchor point on body 2 constrained to the line in world space. ### Remarks Computes local anchor points and axis from the current body poses. Equal or reversed distance limits fix the point at their midpoint. Default values: Bias = DefaultLinearBias, Softness = DefaultLinearSoftness, LimitSoftness = DefaultLinearLimitSoftness, LimitBias = DefaultLinearLimitBias. ### Exceptions - **ArgumentException** - Thrown when `axis` is zero or contains a non-finite value, when `anchor1` or `anchor2` contains a non-finite value, or when either value in `limit` is NaN. ``` -------------------------------- ### Raylib_cs render loop with plane and camera Source: https://jitterphysics.com/docs/tutorials/boxes/render-loop.html Replace the content of Program.cs with this code to set up a Raylib_cs render loop. It initializes a 1200x800 window, creates a textured plane model, sets up a perspective camera, and runs a loop that draws the plane and displays the current FPS until the window is closed. ```csharp using System.Numerics; using Raylib_cs; using static Raylib_cs.Raylib; static Texture2D GenCheckedTexture(int size, int checks, Color colorA, Color colorB) { Image imageMag = GenImageChecked(size, size, checks, checks, colorA, colorB); Texture2D textureMag = LoadTextureFromImage(imageMag); UnloadImage(imageMag); return textureMag; } // set a hint for anti-aliasing SetConfigFlags(ConfigFlags.Msaa4xHint); // initialize a 1200x800 px window with a title InitWindow(1200, 800, "BoxDrop example"); // dynamically create a plane model Texture2D texture = GenCheckedTexture(10, 1, Color.LightGray, Color.Gray); Model planeModel = LoadModelFromMesh(GenMeshPlane(10, 10, 10, 10)); SetMaterialTexture(ref planeModel, 0, MaterialMapIndex.Diffuse, ref texture); // create a camera Camera3D camera = new () { Position = new Vector3(-20.0f, 8.0f, 10.0f), Target = new Vector3(0.0f, 4.0f, 0.0f), Up = new Vector3(0.0f, 1.0f, 0.0f), FovY = 45.0f, Projection = CameraProjection.Perspective }; // 100 fps target SetTargetFPS(100); // simple render loop while (!WindowShouldClose()) { BeginDrawing(); ClearBackground(Color.Blue); BeginMode3D(camera); DrawModel(planeModel, Vector3.Zero, 1.0f, Color.White); EndMode3D(); DrawText($"{GetFPS()} fps", 10, 10, 20, Color.White); EndDrawing(); } CloseWindow(); ``` -------------------------------- ### Overlap Check Example Source: https://jitterphysics.com/docs/documentation/dynamictree.html Example showing how to compose overlap checks by querying the tree with a bounding box and then running an exact narrowphase overlap test against the returned candidates. ```APIDOC ## Overlap Check Example ### Description Example showing how to compose overlap checks by querying the tree with a bounding box first and then running an exact narrowphase overlap test against the returned candidates. ### Example ```csharp // Returns all RigidBodyShapes overlapping a sphere at 'center' with 'radius'. static IEnumerable OverlapSphere(World world, JVector center, float radius) { var queryBox = new JBoundingBox( center - new JVector(radius), center + new JVector(radius)); var candidates = new List(); world.DynamicTree.Query(candidates, queryBox); var querySphere = SupportPrimitives.CreateSphere(radius); foreach (var proxy in candidates) { if (proxy is not RigidBodyShape shape) continue; ref var data = ref shape.RigidBody.Data; bool hit = NarrowPhase.Overlap( querySphere, shape, JQuaternion.Identity, data.Orientation, center, data.Position); if (hit) yield return shape; } } ``` ### Remarks - This pattern is usually enough for overlap checks and avoids introducing additional broadphase API surface. ``` -------------------------------- ### Create and enter BoxDrop directory Source: https://jitterphysics.com/docs/tutorials/boxes/project-setup.html Creates a new directory named 'BoxDrop' and navigates into it. This is the first step in setting up the project structure. ```bash mkdir BoxDrop && cd BoxDrop ``` -------------------------------- ### TriangleMesh.Vertices Source: https://jitterphysics.com/api/Jitter2.Collision.Shapes.TriangleMesh.html Gets the vertices of the mesh. ```APIDOC ## TriangleMesh.Vertices ### Description Gets the vertices of the mesh. ### Property Value `ReadOnlySpan` ### Syntax ```csharp public ReadOnlySpan Vertices { get; } ``` ``` -------------------------------- ### Elements Source: https://jitterphysics.com/api/Jitter2.Unmanaged.PartitionedBuffer-1.html Gets a span over all elements in the buffer. ```APIDOC ## Property ### Elements A span for all elements. #### Property Value - `Span` #### Remarks **Do not cache:** This span is invalidated when the buffer resizes. ``` -------------------------------- ### PartitionedBuffer(int initialSize = 1024, bool aligned64 = false) Source: https://jitterphysics.com/api/Jitter2.Unmanaged.PartitionedBuffer-1.html Initializes a new instance of the PartitionedBuffer class with optional initial size and alignment settings. ```APIDOC ## Constructor ### PartitionedBuffer(int initialSize = 1024, bool aligned64 = false) Initializes a new instance of the class. #### Parameters - `initialSize` (int) - The initial size of the contiguous memory block. - `aligned64` (bool) - Indicates whether the memory should be aligned to 64 bytes. #### Exceptions - `ArgumentException` - Thrown when `T` is too small to store the internal element ID. - `ArgumentOutOfRangeException` - Thrown when `initialSize` is less than one or exceeds the maximum capacity. ``` -------------------------------- ### Thickness Source: https://jitterphysics.com/api/Jitter2.SoftBodies.SoftBodyTriangle.html Gets or sets the thickness of the triangle. ```APIDOC ## Property: Thickness ### Description Gets or sets the thickness of the triangle. ### Signature ```csharp public float Thickness { get; set; } ``` ### Property Value - `float` - The thickness value. ``` -------------------------------- ### Initialize Method (4 parameters) Source: https://jitterphysics.com/api/Jitter2.Dynamics.Constraints.PointOnLine.html Initializes the constraint from world-space parameters with a distance limit. ```APIDOC ## Method: Initialize (4 parameters) ### Description Initializes the constraint from world-space parameters with a distance limit. ### Signature ```csharp public void Initialize(JVector axis, JVector anchor1, JVector anchor2, LinearLimit limit) ``` ### Parameters - **axis** (JVector) - The line axis in world space, fixed in the reference frame of body 1. - **anchor1** (JVector) - Anchor point on body 1 defining the line origin in world space. - **anchor2** (JVector) - Anchor point on body 2 constrained to the line in world space. - **limit** (LinearLimit) - Distance limit along the axis. ### Remarks Computes local anchor points and axis from the current body poses. Equal or reversed distance limits fix the point at their midpoint. Default values: Bias = DefaultLinearBias, Softness = DefaultLinearSoftness, LimitSoftness = DefaultLinearLimitSoftness, LimitBias = DefaultLinearLimitBias. ### Exceptions - **ArgumentException** - Thrown when `axis` is zero or contains a non-finite value, when `anchor1` or `anchor2` contains a non-finite value, or when either value in `limit` is NaN. ``` -------------------------------- ### TriangleMesh.Indices Source: https://jitterphysics.com/api/Jitter2.Collision.Shapes.TriangleMesh.html Gets the triangle indices of the mesh. ```APIDOC ## TriangleMesh.Indices ### Description Gets the triangle indices of the mesh. ### Property Value `ReadOnlySpan` ### Syntax ```csharp public ReadOnlySpan Indices { get; } ``` ``` -------------------------------- ### Create and enter TeaDrop directory Source: https://jitterphysics.com/docs/tutorials/teapots/project-setup.html Creates a new directory named TeaDrop and navigates into it, providing the workspace for the project. ```bash mkdir TeaDrop && cd TeaDrop ``` -------------------------------- ### Jitter2 and Raylib teapot physics simulation Source: https://jitterphysics.com/docs/tutorials/teapots/hello-world.html Complete C# example that integrates Jitter2 physics with Raylib to simulate falling teapots. It creates a static plane and multiple dynamic teapot bodies using a PointCloudShape sampled from a loaded model, then renders them in a 3D loop. Requires the teapot.obj file and the Jitter2, Raylib-cs, and System.Numerics packages. ```csharp using System.Numerics; using Raylib_cs; using Jitter2; using Jitter2.Collision.Shapes; using Jitter2.Dynamics; using Jitter2.LinearMath; using static Raylib_cs.Raylib; static Matrix4x4 GetRayLibTransformMatrix(RigidBody body) { JMatrix ori = JMatrix.CreateFromQuaternion(body.Orientation); JVector pos = body.Position; return new Matrix4x4(ori.M11, ori.M12, ori.M13, pos.X, ori.M21, ori.M22, ori.M23, pos.Y, ori.M31, ori.M32, ori.M33, pos.Z, 0, 0, 0, 1.0f); } static Texture2D GenCheckedTexture(int size, int checks, Color colorA, Color colorB) { Image imageMag = GenImageChecked(size, size, checks, checks, colorA, colorB); Texture2D textureMag = LoadTextureFromImage(imageMag); UnloadImage(imageMag); return textureMag; } const int numberOfTeapots = 12; // set a hint for anti-aliasing SetConfigFlags(ConfigFlags.Msaa4xHint); // initialize a 1200x800 px window with a title InitWindow(1200, 800, "TeaDrop example"); // dynamically create a plane model Texture2D texture = GenCheckedTexture(10, 1, Color.LightGray, Color.Gray); Model planeModel = LoadModelFromMesh(GenMeshPlane(20, 20, 10, 10)); SetMaterialTexture(ref planeModel, 0, MaterialMapIndex.Diffuse, ref texture); // load the teapot model from file Model teapotModel = LoadModel("teapot.obj"); // load the mesh vertices if (teapotModel.MeshCount == 0) throw new Exception("Model could not be loaded!"); Mesh teapotMesh; unsafe { teapotMesh = teapotModel.Meshes[0]; } var allVertices = teapotMesh.VerticesAs(); // sample vertices on the convex hull var vertices = ShapeHelper.SampleHull(allVertices, 4); // create the PointCloudShape from the reduced vertices var pointCloudShape = new PointCloudShape(vertices); // shift the shape, such that the center of mass is at the origin pointCloudShape.GetCenter(out JVector center); pointCloudShape.Shift = -center; // we need to take the transpose here, since Raylib and System.Numerics // use a different convention Matrix4x4 shift = Matrix4x4.CreateTranslation(-center); shift = Matrix4x4.Transpose(shift); texture = GenCheckedTexture(16, 2, Color.White, Color.Magenta); Material teapotMat = LoadMaterialDefault(); SetMaterialTexture(ref teapotMat, MaterialMapIndex.Diffuse, texture); // initialize the Jitter physics world World world = new (); world.SubstepCount = 4; // add a body representing the plane RigidBody planeBody = world.CreateRigidBody(); planeBody.AddShape(new BoxShape(20)); planeBody.Position = new JVector(0, -10, 0); planeBody.MotionType = MotionType.Static; // add numberOfTeapots teapots for(int i = 0; i < numberOfTeapots; i++) { RigidBody body = world.CreateRigidBody(); body.AddShape(pointCloudShape.Clone()); body.Position = new JVector(0, i * 4 + 0.5f, 0); } // create a camera Camera3D camera = new () { Position = new Vector3(-40.0f, 16.0f, 20.0f), Target = new Vector3(0.0f, 4.0f, 0.0f), Up = new Vector3(0.0f, 1.0f, 0.0f), FovY = 45.0f, Projection = CameraProjection.Perspective }; // 100 fps target SetTargetFPS(100); // simple render loop while (!WindowShouldClose()) { BeginDrawing(); ClearBackground(Color.Blue); BeginMode3D(camera); DrawModel(planeModel, Vector3.Zero, 1.0f, Color.White); world.Step(1.0f / 100.0f, true); foreach(var body in world.RigidBodies) { if (body == planeBody || body == world.NullBody) continue; // do not draw this DrawMesh(teapotMesh, teapotMat, GetRayLibTransformMatrix(body) * shift); } EndMode3D(); DrawText($"{GetFPS()} fps", 10, 10, 20, Color.White); EndDrawing(); } CloseWindow(); ``` -------------------------------- ### World Source: https://jitterphysics.com/api/Jitter2.Dynamics.RigidBody.html Property to get the world assigned to this body. ```APIDOC ## Property: World ### Description Gets or sets the world assigned to this body. ### Property Value World ``` -------------------------------- ### Initialize method signature Source: https://jitterphysics.com/api/Jitter2.Dynamics.ContactData.Contact.html Method signature for initializing the contact with two rigid bodies, contact points, normal, new-contact flag, and restitution. ```csharp public void Initialize(ref RigidBodyData b1, ref RigidBodyData b2, in JVector point1, in JVector point2, in JVector n, bool newContact, float restitution)__ ``` -------------------------------- ### Mass Source: https://jitterphysics.com/api/Jitter2.Dynamics.RigidBody.html Property to get the mass of the rigid body. ```APIDOC ## Mass ### Description Gets the mass of the rigid body. To modify the mass, use SetMassInertia(float) or SetMassInertia(in JMatrix, float, bool). ### Property Value float ### Remarks This value is only meaningful for Dynamic bodies. Static and kinematic bodies are treated as having infinite mass by the solver regardless of this value. ### Syntax ```csharp public float Mass { get; } ``` ``` -------------------------------- ### Configure Substep Count and Solver Iterations Source: https://jitterphysics.com/docs/documentation/world.html Divides the time step into smaller steps, each solved with the specified solver iterations. This example performs 12 solver iterations per call to world.Step, improving stability at the cost of slower runtime. ```csharp world.SubstepCount = 4; world.SolverIterations = (solver: 2, relaxation: 1); ``` -------------------------------- ### Inactive Source: https://jitterphysics.com/api/Jitter2.Unmanaged.PartitionedBuffer-1.html Gets a span over all inactive elements in the buffer. ```APIDOC ## Property ### Inactive A span for all elements marked as inactive. #### Property Value - `Span` #### Remarks **Do not cache:** This span is invalidated when the buffer resizes. ``` -------------------------------- ### World.CreateRigidBody() Source: https://jitterphysics.com/api/Jitter2.World.html Creates and adds a new RigidBody to the simulation world. Raises PartitionedBuffer.MaximumSizeException when the rigid-body buffer exceeds its maximum size. ```csharp public RigidBody CreateRigidBody()__ ``` -------------------------------- ### Count Source: https://jitterphysics.com/api/Jitter2.Unmanaged.PartitionedBuffer-1.html Gets the number of allocated elements in the buffer. ```APIDOC ## Property ### Count Gets the number of allocated elements in the buffer. #### Property Value - `int` ``` -------------------------------- ### PrepareForIteration(float) Source: https://jitterphysics.com/api/Jitter2.Dynamics.ContactData.html Prepares all active contacts for solver iterations by computing effective masses and warm-starting impulses. ```APIDOC ## PrepareForIteration(float) ### Description Prepares all active contacts for solver iterations by computing effective masses and warm-starting impulses. ### Method PrepareForIteration ### Parameters - **idt** (float) - Inverse of the timestep (1/dt). ### Example ```csharp public void PrepareForIteration(float idt) ``` ``` -------------------------------- ### Active Source: https://jitterphysics.com/api/Jitter2.Unmanaged.PartitionedBuffer-1.html Gets a span over all active elements in the buffer. ```APIDOC ## Property ### Active A span for all elements marked as active. #### Property Value - `Span` #### Remarks **Do not cache:** This span is invalidated when the buffer resizes. ``` -------------------------------- ### GetColumn(int) Source: https://jitterphysics.com/api/Jitter2.LinearMath.JMatrix.html Gets a column vector by index. ```APIDOC ## GetColumn(int) ### Description Gets a column vector by index. ### Method GetColumn ### Signature `public JVector GetColumn(int index)` ### Parameters - **index** (int) - Required - The zero-based index of the column (0, 1, or 2). ### Returns - **JVector** - The column vector. ``` -------------------------------- ### PrepareForIterationAccelerated method signature Source: https://jitterphysics.com/api/Jitter2.Dynamics.ContactData.Contact.html Method signature for accelerated preparation for iteration. ```csharp public void PrepareForIterationAccelerated(ContactData* cd, float idt)__ ``` -------------------------------- ### CreateFromQuaternion method signature (out parameter) Source: https://jitterphysics.com/api/Jitter2.LinearMath.JMatrix.html Creates a rotation matrix from a quaternion and stores the result in the output parameter. ```csharp public static void CreateFromQuaternion(in JQuaternion quaternion, out JMatrix result) ``` -------------------------------- ### JBoundingBox.Center Source: https://jitterphysics.com/api/Jitter2.LinearMath.JBoundingBox.html Gets the center point of the bounding box. ```APIDOC ## Property: Center ### Description Gets the center point of the bounding box. ### Property Value JVector ### Syntax ```csharp public readonly JVector Center { get; } ``` ``` -------------------------------- ### JAngle.Radian Source: https://jitterphysics.com/api/Jitter2.LinearMath.JAngle.html Gets or sets the angle value in radians. ```APIDOC ## Property: Radian ### Description Gets or sets the angle value in radians. ### Signature ```csharp public float Radian { readonly get; set; } ``` ### Property Value float ``` -------------------------------- ### Step(float, bool) Performs Simulation Step Source: https://jitterphysics.com/api/Jitter2.World.html Performs a single simulation step. The step is divided into SubstepCount substeps for stability. dt should remain fixed and not exceed 1/60 s. Throws ArgumentException if dt is negative or not finite. ```csharp public void Step(float dt, bool multiThread = true)__ ``` -------------------------------- ### CreateFromQuaternion method signature (returning JMatrix) Source: https://jitterphysics.com/api/Jitter2.LinearMath.JMatrix.html Creates a rotation matrix from a quaternion. ```csharp public static JMatrix CreateFromQuaternion(JQuaternion quaternion) ``` -------------------------------- ### JAngle.Degree Source: https://jitterphysics.com/api/Jitter2.LinearMath.JAngle.html Gets or sets the angle value in degrees. ```APIDOC ## Property: Degree ### Description Gets or sets the angle value in degrees. ### Signature ```csharp public float Degree { readonly get; set; } ``` ### Property Value float ``` -------------------------------- ### TreeBox.Center Source: https://jitterphysics.com/api/Jitter2.Collision.TreeBox.html Gets the center point of the bounding box. ```APIDOC ## TreeBox.Center ### Description Gets the center point of the bounding box. ### Property Value JVector ### Syntax ```csharp public readonly JVector Center { get; } ``` ``` -------------------------------- ### Sample convex hull vertices with ShapeHelper.SampleHull in C# Source: https://jitterphysics.com/docs/tutorials/teapots/hull-sampling.html Replaces Program.cs to load a teapot model, sample its convex hull vertices with ShapeHelper.SampleHull, and visualize the model, sampled vertices, and explicit hull using Raylib. Requires the teapot.obj file and Jitter2. The sampled vertices are drawn as red spheres, the hull edges as green lines, and the model wireframe in white. ```csharp using System.Numerics; using Jitter2.Collision.Shapes; using Jitter2.LinearMath; using Raylib_cs; using static Raylib_cs.Raylib; // set a hint for anti-aliasing SetConfigFlags(ConfigFlags.Msaa4xHint); // initialize a 1200x800 px window with a title InitWindow(1200, 800, "TeaDrop example"); // load the teapot model from a file Model teapotModel = LoadModel("teapot.obj"); // load the mesh vertices if (teapotModel.MeshCount == 0) throw new Exception("Model could not be loaded!"); Mesh mesh; unsafe { mesh = teapotModel.Meshes[0]; } var allVertices = mesh.VerticesAs(); var vertices = ShapeHelper.SampleHull(allVertices, 4); // just for visualization - // we will not need to construct the explicit hull for the simulation! var debugHull = ShapeHelper.Tessellate(vertices, 4); // create a camera Camera3D camera = new () { Position = new Vector3(-5.0f, 2.0f, 3.0f), Target = new Vector3(0.0f, 1.0f, 0.0f), Up = new Vector3(0.0f, 1.0f, 0.0f), FovY = 45.0f, Projection = CameraProjection.Perspective }; // 100 fps target SetTargetFPS(100); // simple render loop while (!WindowShouldClose()) { BeginDrawing(); ClearBackground(Color.Blue); // make the scene rotate UpdateCamera(ref camera, CameraMode.Orbital); BeginMode3D(camera); // draw the teapot model DrawModelWires(teapotModel, Vector3.Zero, 1.0f, Color.White); // draw the sample vertices of the convex hull foreach (var vertex in vertices) { DrawSphere(vertex, 0.02f, Color.Red); } // for debugging: draw the explicit hull foreach (var vertex in debugHull) { DrawLine3D(vertex.V0, vertex.V1, Color.Green); DrawLine3D(vertex.V1, vertex.V2, Color.Green); DrawLine3D(vertex.V2, vertex.V0, Color.Green); } EndMode3D(); DrawText($"{GetFPS()} fps", 10, 10, 20, Color.White); EndDrawing(); } CloseWindow(); ``` -------------------------------- ### Assigning TeamFilter to world.BroadPhaseFilter Source: https://jitterphysics.com/docs/documentation/filters.html Shows how to instantiate the TeamFilter and assign it to world.BroadPhaseFilter, then set body tags to assign team membership. ```csharp world.BroadPhaseFilter = new TeamFilter(); ... bodyA.Tag = TeamFilter.TeamBlue; bodyB.Tag = TeamFilter.TeamRed; bodyC.Tag = TeamFilter.TeamRed; ``` -------------------------------- ### LinearLimit.To Source: https://jitterphysics.com/api/Jitter2.Dynamics.Constraints.LinearLimit.html Gets or sets the maximum distance of the limit. ```APIDOC ## LinearLimit.To ### Description Gets or sets the maximum distance of the limit. ### Property `public float To { readonly get; set; }` ### Property Value - **float** - The maximum distance. ``` -------------------------------- ### Create a rigid body with World.CreateRigidBody Source: https://jitterphysics.com/docs/documentation/bodies.html Creates a World instance and a rigid body associated with it. The body is the main entity of the dynamics system. ```csharp var world = new World(); var body = world.CreateRigidBody(); ``` -------------------------------- ### LinearLimit.From Source: https://jitterphysics.com/api/Jitter2.Dynamics.Constraints.LinearLimit.html Gets or sets the minimum distance of the limit. ```APIDOC ## LinearLimit.From ### Description Gets or sets the minimum distance of the limit. ### Property `public float From { readonly get; set; }` ### Property Value - **float** - The minimum distance. ``` -------------------------------- ### Count Property Source: https://jitterphysics.com/api/Jitter2.DataStructures.ReadOnlyHashSet-1.html Gets the number of elements in the set. ```APIDOC ## Count Property ### Description Gets the number of elements in the set. ### Property Value - **int** - The number of elements in the set. ``` -------------------------------- ### BoxShape.Size Source: https://jitterphysics.com/api/Jitter2.Collision.Shapes.BoxShape.html Gets or sets the dimensions of the box shape. ```APIDOC ## Property: Size ### Description Gets or sets the dimensions of the box. ### Property Value JVector ### Exceptions - **ArgumentOutOfRangeException** - Thrown when any component of `value` is less than or equal to zero. ### Syntax ```csharp public JVector Size { get; set; } ``` ``` -------------------------------- ### Init(RigidBody, RigidBody) Source: https://jitterphysics.com/api/Jitter2.Dynamics.ContactData.html Initializes this contact data for a pair of rigid bodies. ```APIDOC ## Init(RigidBody, RigidBody) ### Description Initializes this contact data for a pair of rigid bodies. ### Method Init ### Parameters - **body1** (RigidBody) - The first rigid body. - **body2** (RigidBody) - The second rigid body. ### Example ```csharp public void Init(RigidBody body1, RigidBody body2) ``` ``` -------------------------------- ### Radius Source: https://jitterphysics.com/api/Jitter2.Collision.Shapes.CapsuleShape.html Property to get or set the radius of the capsule. ```APIDOC ## Radius Property ### Description Gets or sets the radius of the capsule. ### Property Signature `public float Radius { get; set; }` ### Property Value - **float** - The radius of the capsule. ### Exceptions - **ArgumentOutOfRangeException** - Thrown when `value` is less than or equal to zero. ``` -------------------------------- ### Initialize(JVector, JVector, LinearLimit) Source: https://jitterphysics.com/api/Jitter2.Dynamics.Constraints.DistanceLimit.html Initializes the constraint with distance limits between anchor points. ```APIDOC ## Initialize(JVector, JVector, LinearLimit) ### Description Initializes the constraint with distance limits between anchor points. ### Method Initialize ### Signature ```csharp public void Initialize(JVector anchor1, JVector anchor2, LinearLimit limit) ``` ### Parameters - **anchor1** (JVector) - Required - Anchor point on the first body in world space. - **anchor2** (JVector) - Required - Anchor point on the second body in world space. - **limit** (LinearLimit) - Required - The allowed distance range between anchor points. ### Remarks Computes local anchor points and the initial distance from current poses. Equal or reversed limits fix the distance offset at their midpoint. Default values: Softness = DefaultLinearSoftness, Bias = DefaultLinearBias. ### Exceptions - **ArgumentException** - Thrown when `anchor1` or `anchor2` contains a non-finite value, or when either value in `limit` is NaN. ### Returns void ``` -------------------------------- ### CreateFromMatrix(in JMatrix, out JQuaternion) Source: https://jitterphysics.com/api/Jitter2.LinearMath.JQuaternion.html Creates a quaternion from a rotation matrix and outputs the result. ```APIDOC ## CreateFromMatrix(in JMatrix, out JQuaternion) ### Description Creates a quaternion from a rotation matrix. ### Method CreateFromMatrix ### Signature ```csharp public static void CreateFromMatrix(in JMatrix matrix, out JQuaternion result) ``` ### Parameters - **matrix** (JMatrix) - The rotation matrix. - **result** (JQuaternion) - Output: The quaternion representing the rotation. ``` -------------------------------- ### Island.Bodies Source: https://jitterphysics.com/api/Jitter2.Collision.Island.html Gets a collection of all the bodies present in this island. ```APIDOC ## Island.Bodies ### Description Gets a collection of all the bodies present in this island. ### Property `public ReadOnlyHashSet Bodies { get; }` ### Property Value `ReadOnlyHashSet` - A read-only set of rigid bodies in the island. ``` -------------------------------- ### Fixed time step accumulation example Source: https://jitterphysics.com/docs/documentation/world.html Recommended pattern for fixed time stepping. Accumulates delta times and calls world.Step only at fixed intervals (here 1/100 s). The maxSteps guard prevents spiral of death when the simulation cannot keep up with real time. ```csharp private float accumulatedTime = 0.0f; public void FixedTimeStep(float dt, int maxSteps = 4) { const float fixedStep = 1.0f / 100.0f; int steps = 0; accumulatedTime += dt; while (accumulatedTime >= fixedStep) { world.Step(fixedStep); accumulatedTime -= fixedStep; // we cannot keep up with real time, i.e. the simulation // is running slower than the real time is passing. if (++steps >= maxSteps) return; } } ``` -------------------------------- ### GetVertex(int) Source: https://jitterphysics.com/api/Jitter2.Collision.ConvexPolytope.html Gets a reference to a vertex by index. ```APIDOC ## GetVertex(int) ### Description Gets a reference to a vertex by index. ### Method GetVertex ### Signature public ref MinkowskiDifference.Vertex GetVertex(int index) ### Parameters - **index** (int) - Required - The index of the vertex. ### Returns - **MinkowskiDifference.Vertex** - A reference to the vertex. ``` -------------------------------- ### CreateScale method signature (float, float, float) Source: https://jitterphysics.com/api/Jitter2.LinearMath.JMatrix.html Creates a scaling matrix from individual scaling factors for each axis. ```csharp public static JMatrix CreateScale(float x, float y, float z) ``` -------------------------------- ### World property Source: https://jitterphysics.com/api/Jitter2.Dynamics.RigidBody.html Gets or sets the world assigned to this body. ```csharp public World World { get; } ``` -------------------------------- ### IsActive Source: https://jitterphysics.com/api/Jitter2.Dynamics.RigidBody.html Property to get whether the rigid body is active. ```APIDOC ## IsActive ### Description Indicates whether the rigid body is active or considered to be in a sleeping state. Use SetActivationState(bool) to alter the activation state. ### Property Value bool ### Syntax ```csharp public bool IsActive { get; } ``` ``` -------------------------------- ### Download and unzip teapot.obj Source: https://jitterphysics.com/docs/tutorials/teapots/project-setup.html Downloads and unzips the teapot.obj model from the Jitter2 repository, placing the model file in the current directory. ```bash wget https://github.com/notgiven688/jitterphysics2/raw/refs/heads/main/src/JitterDemo/assets/teapot.obj.zip unzip teapot.obj.zip ``` -------------------------------- ### PrepareForIteration method signature Source: https://jitterphysics.com/api/Jitter2.Dynamics.ContactData.Contact.html Method signature for preparing the contact for iteration with an inverse timestep. ```csharp public void PrepareForIteration(ContactData* cd, float idt)__ ``` -------------------------------- ### Handle Source: https://jitterphysics.com/api/Jitter2.Dynamics.RigidBody.html Property to get the handle to the rigid body data. ```APIDOC ## Handle ### Description Gets the handle to the rigid body data, see Data. ### Property Value JHandle ### Syntax ```csharp public JHandle Handle { get; } ``` ``` -------------------------------- ### UnsafeGet(int) Source: https://jitterphysics.com/api/Jitter2.LinearMath.JVector.html Gets a reference to the element at the specified index. ```APIDOC ## UnsafeGet(int) ### Description Gets a reference to the element at the specified index. ### Method UnsafeGet ### Signature public ref float UnsafeGet(int index) ### Parameters - **index** (int) - Required - The index of the element. ### Returns float - A reference to the element. ``` -------------------------------- ### PrepareForIterationPointOnLine Method Source: https://jitterphysics.com/api/Jitter2.Dynamics.Constraints.PointOnLine.html Static method to prepare the point-on-line constraint for iteration. ```APIDOC ## Method: PrepareForIterationPointOnLine ### Description Static method to prepare the point-on-line constraint for iteration. ### Signature ```csharp public static void PrepareForIterationPointOnLine(ref ConstraintData constraint, float idt) ``` ### Parameters - **constraint** (ConstraintData) - The constraint data. - **idt** (float) - The inverse delta time. ``` -------------------------------- ### Single-threaded stepping for parallel worlds Source: https://jitterphysics.com/docs/documentation/world.html Recommended setup for stepping multiple independent worlds in parallel. Each world uses single-threaded stepping to avoid contention on Jitter's process-wide worker pool. ```csharp world.Step(dt, multiThread: false); world.Stabilize(dt, iterations, multiThread: false); ``` -------------------------------- ### Proxies Source: https://jitterphysics.com/api/Jitter2.Collision.DynamicTree.html Gets a read-only view of all proxies registered with this tree. ```APIDOC ## Property: Proxies ### Description Gets a read-only view of all proxies registered with this tree. ### Property Signature ```csharp public ReadOnlyPartitionedSet Proxies { get; } ``` ### Property Value - **Type**: ReadOnlyPartitionedSet ``` -------------------------------- ### CreateRigidBody() Source: https://jitterphysics.com/api/Jitter2.World.html Creates and adds a new rigid body to the simulation world. ```APIDOC ## CreateRigidBody() ### Description Creates and adds a new rigid body to the simulation world. ### Method CreateRigidBody ### Signature ```csharp public RigidBody CreateRigidBody() ``` ### Parameters None. ### Returns - **RigidBody** - A newly created instance of RigidBody. ### Exceptions - **PartitionedBuffer.MaximumSizeException** - Raised when the rigid-body buffer maximum size is exceeded. ``` -------------------------------- ### World.SpanData.InactiveContacts Property Source: https://jitterphysics.com/api/Jitter2.World.SpanData.html Gets a span over inactive contact data. ```APIDOC ## Property: InactiveContacts ### Description Gets a span over inactive contact data. ### Signature ```csharp public Span InactiveContacts { get; } ``` ### Property Value - **Span** - A span over inactive contact data. ``` -------------------------------- ### Configure TeaDrop.csproj for unsafe code and teapot.obj Source: https://jitterphysics.com/docs/tutorials/teapots/project-setup.html Adds to TeaDrop.csproj to enable unsafe code and to copy teapot.obj to the output directory on every build. ```xml true Always ``` -------------------------------- ### World.SpanData.InactiveConstraints Property Source: https://jitterphysics.com/api/Jitter2.World.SpanData.html Gets a span over inactive constraint data. ```APIDOC ## Property: InactiveConstraints ### Description Gets a span over inactive constraint data. ### Signature ```csharp public Span InactiveConstraints { get; } ``` ### Property Value - **Span** - A span over inactive constraint data. ``` -------------------------------- ### World.SpanData.ActiveContacts Property Source: https://jitterphysics.com/api/Jitter2.World.SpanData.html Gets a span over active contact data. ```APIDOC ## Property: ActiveContacts ### Description Gets a span over active contact data. ### Signature ```csharp public Span ActiveContacts { get; } ``` ### Property Value - **Span** - A span over active contact data. ``` -------------------------------- ### CreateFromQuaternion(in JQuaternion, out JMatrix) Source: https://jitterphysics.com/api/Jitter2.LinearMath.JMatrix.html Creates a rotation matrix from a quaternion and stores the result in an output parameter. ```APIDOC ## CreateFromQuaternion(in JQuaternion, out JMatrix) ### Description Creates a rotation matrix from a quaternion. ### Method CreateFromQuaternion ### Signature public static void CreateFromQuaternion(in JQuaternion quaternion, out JMatrix result) ### Parameters - **quaternion** (JQuaternion) - The quaternion representing the rotation. - **result** (JMatrix) - Output: The rotation matrix. ### Returns void ``` -------------------------------- ### World.SpanData.ActiveConstraints Property Source: https://jitterphysics.com/api/Jitter2.World.SpanData.html Gets a span over active constraint data. ```APIDOC ## Property: ActiveConstraints ### Description Gets a span over active constraint data. ### Signature ```csharp public Span ActiveConstraints { get; } ``` ### Property Value - **Span** - A span over active constraint data. ``` -------------------------------- ### DynamicTree.RayCastFilterPre Source: https://jitterphysics.com/api/Jitter2.Collision.DynamicTree.RayCastFilterPre.html Documentation for the DynamicTree.RayCastFilterPre delegate. ```APIDOC ## Delegate DynamicTree.RayCastFilterPre ### Description Delegate for filtering ray cast candidates before the shape intersection test. ### Definition ```csharp public delegate bool DynamicTree.RayCastFilterPre(IDynamicTreeProxy proxy) ``` ### Parameters - **proxy** (IDynamicTreeProxy) - The proxy to evaluate. ### Returns - **bool** - `false` to skip this proxy; `true` to test it. ``` -------------------------------- ### this[int] Source: https://jitterphysics.com/api/Jitter2.LinearMath.JVector.html Gets or sets the component of the vector at the specified index. ```APIDOC ## this[int] ### Description Gets or sets the component of the vector at the specified index. ### Method Indexer ### Parameters - **i** (int) - The index of the component to get or set. ### Property Value float - The component value at the specified index. ``` -------------------------------- ### Island() Source: https://jitterphysics.com/api/Jitter2.Collision.Island.html Initializes a new instance of the Island class. ```APIDOC ## Island() ### Description Initializes a new instance of the Island class. ### Constructor `public Island()` ### Parameters None. ### Returns A new instance of the Island class. ``` -------------------------------- ### SoftBodyShape.GetClosest Source: https://jitterphysics.com/api/Jitter2.SoftBodies.SoftBodyShape.html Gets the rigid body closest to a specified position. ```APIDOC ## SoftBodyShape.GetClosest(in JVector) ### Description Gets the rigid body closest to the specified position. ### Method `public abstract RigidBody GetClosest(in JVector pos)` ### Parameters - **pos** (JVector) - The position in world coordinates. ### Returns - **RigidBody** - The closest rigid body (vertex) of this shape. ```