Skip to content

Releases: jaipack17/Nature2D

Anchor Point Support

14 Nov 05:46
Compare
Choose a tag to compare

Anchor Point Support

  • Added Anchor point support
  • Added new methods to RigidBodies
    • RigidBody:GetCenter()
  • Added new methods to Points
    • Point:SetPosition(newPosition: Vector2)
  • Bug fixes
    • Fixed Parent hierarchy errors in Points.
    • Fixed Point:Update() "Cannot read property 'Parent' of nil" errors.
    • Fixed Point:KeepInCanvas() "Cannot read property 'Parent' of nil" errors.

Major Improvements to Frictional Forces

12 Nov 09:50
e8012fa
Compare
Choose a tag to compare

Major Improvements to Frictional Forces

Linked Pull Request - #4

  • Fixed a bug where changes to physical properties before creating any RigidBodies, Constraints or Points won't affect/apply to newly created objects.
  • Friction only applies if RigidBodies collide with each other or the edges of the canvas. If none of those conditions are true, AirFriction is applied.
  • Added AirFriction physical property to Engine, Points and RigidBodies. Frictional force applied when a RigidBody neither touches another body nor the edges of canvas.
    • Engine:SetPhysicalProperty("AirFriction", 0.1)
  • Friction and AirFriction are set to 0.01 by default. (0.99 damping value).
  • Changed how we pass parameters when initializing or updating friction of the engine or rigidbodies. The closer the friction to 1, the higher it is. The closer the friction to 0, the lower it is. Same applies for AirFriction. Values not in the range of 0-1 are automatically clamped down.
  • Added new Methods to RigidBodies
    • RigidBody:SetAirFriction(airfriction: number)

Fixes to Collision Detection & New Methods

10 Nov 05:51
Compare
Choose a tag to compare

Fixes to Collision Detection & New Methods

  • Made restLength: number? an optional parameter for Engine:CreateConstraint().
  • Fixes to Collision Detection - Collision detection is no longer skipped at low frame rates.
  • Fixed how forces are applied to Points when the engine is framerate independent.
  • Added new methods to Engine
    • Engine:FrameRateIndependent(independent: boolean) - Determines if Frame rate does not affect the simulation speed. By default set to true.
  • Added new methods to Constraint
    • Constraint:GetParent()
  • Added new methods to Point
    • Point:GetParent()

New Constraint Types!

09 Nov 06:31
Compare
Choose a tag to compare

v0.3 - New Constraints: Ropes, Rods & Springs!

Major Release.

  • Checks to prevent division by 0.
  • Fix Constraint:SetLength(). Disregard invalid lengths. (length <= 0)
  • Fix Engine:CreateConstraint(). Disregard invalid thickness and lengths. (length & thickness <= 0)
  • Added new methods to Constraint
    • Constraint:SetSpringConstant(k: number)
    • Constraint:GetId()
  • New "type" paramater to Engine:CreateConstraint()
  • New "restLength" parameter to Engine:CreateConstraint()
    • Engine:CreateConstraint(Type: string, point1: Point, point2: Point, visible: boolean, thickness: number, restLength: number)
  • Added rope constraint type
    • Constraints that have an upper constrain limit and exclusive of a lower limit. Similar to Roblox's 3D Rope Constraints.
  • Added rod constraint type
    • These constraints are similar to how Rope constraints function. But unlike rope constraints, these constraints have a fixed amount of space between its points and aren't flexible. These constraints can move in all directions just how rope constraints can, but the space between them remains constant.
  • Added spring constraint type
    • Spring constraints are elastic, wonky and flexible. Perfect for various simulations that require springs. Achieved using Hooke's Law.
  • Type parameter in Engine:CreateConstraint() must be "SPRING", "ROD" or "ROPE" (text case does not matter).

Previously

  • Added state management for RigidBodies. Individual RigidBodies can have their own States/Custom Properties now!
    • RigidBody:SetState(state: string, value: any)
    • RigidBody:GetState(state: string)
  • Add type definitions & annotations
  • Type check everything (almost)
  • Removed code redundancies
  • Replaced deprecations
    • Vector2.xVector2.X
    • Vector2.yVector2.Y
    • Vector2.magnitudeVector2.Magnitude
    • Vector2.unitVector2.Unit
    • … etc

Improvements to Code

02 Nov 06:13
Compare
Choose a tag to compare

Improvements to Code

  • Add type definitions & annotations
  • Type check everything (almost)
  • Remove code redundancies
  • Replace deprecations
    • Vector2.x -> Vector2.X
    • Vector2.y -> Vector2.Y
    • Vector2.magnitude -> Vector2.Magnitude
    • Vector2.unit -> Vector2.Unit
    • ... etc

State Management

01 Nov 15:53
Compare
Choose a tag to compare

State Management

Added state management for RigidBodies. Individual RigidBodies can have their own States/Custom Properties now!

  • RigidBody:SetState(state: string, value: any)
  • RigidBody:GetState(state: string)

Example usage:

local Body = Engine:CreateRigidBody(frame, true, false)
Body:SetState("Health", 100)

local Killbrick = Engine:CreateRigidBody(frame2, true, true)

Killbrick.Touched:Connect(function(bodyID)
    if Body:GetId() == bodyID then
        local oldHealth = Body:GetState("Health")
        Body:SetState("Health", oldHealth - 1)
        return
    end
end)

Quadtrees in Collision Detection!

28 Oct 04:30
Compare
Choose a tag to compare

Quadtrees in Collision Detection!

Quadtrees have now been implemented into the collision detection algorithm making the engine 10 times faster than before. Instead of wasting resources on wasted and unnecessary collision detection checks, RigidBodies are now distributed into different regions of a quadtree with a collision hit range. RigidBodies only in this hit range are processed with collision detection checks. This opens the gate for many new creations that required a larger amount of RigidBodies to be simulated!

Since Quadtrees are still in beta, there may occur bugs and unwanted behavior. If you encounter any, be sure to open an issue at the github repository. I'll be adding configuration methods for you to switch between traditional methods of collision detection or quadtrees.

Quadtrees in the works!

26 Oct 12:06
Compare
Choose a tag to compare

Quadtrees in the works!

  • Collision Detection is now being re-written, with the addition of quadtrees!
  • Fixed RigidBody:Destroy() Connections are now destroyed when RigidBody:Destroy() is called.
  • Added new methods to Points
    • Point:Velocity()
  • Added new methods to RigidBodies
    • RigidBody:AverageVelocity()
  • Added new methods to Constraints
    • Constraint:GetPoints()
    • Constraint:GetFrame()
  • Fixed Constraint:Destroy(). Does not spam errors if connected to a RigidBody now.

gif

Additions to Constraints, Engine and RigidBodies.

25 Oct 11:26
Compare
Choose a tag to compare

Additions to Constraints, Engine and RigidBodies.

  • Added new methods to Constraints
  • Added new methods to RigidBodies
  • Added new events to Engine
    • Engine.Started
    • Engine.Stopped
engine.Started:Connect(function()
    -- fires when the engine starts
end)

engine.Stopped:Connect(function()
    -- fires when the engine stops
end)

Fixes and New Stuff!

23 Oct 05:32
f106c2a
Compare
Choose a tag to compare

Fixes and New Stuff!

  • The library now utilizes sleitnick's Signal class instead of bindable events.
    • RigidBody.CanvasEdgeTouched:Connect()
    • RigidBody.Touched:Connect()
  • Bug Fixes
    • Error Handling
  • Improved code - Removed bad practices
  • RigidBody.CanvasEdgeTouched event returns the edge the RigidBody collides with.
  • Added new methods to Engine

Added new example which covers the concept of creating Custom Constraints, where we create the following simulation of a RigidBody hanging from a rope, and wind forces being applied on it.

rope