LessSimpleZone | A more precise & optimized extension of SimpleZone

LessSimpleZone is a SimpleZone wrapper that provides extra features such as getting random points, checking if a point is inside the zone, updating volume, and combining zones, alongside the features of SimpleZone itself (as LessSimpleZone inherits from it), at the cost of more complexity in the code.

Documentation (not including SimpleZone):

Constructor
  1. LessSimpleZone.fromBoxes(boxes: {{cframe: CFrame, size: Vector3}}, queryOp: QueryOptions?): LessSimpleZone

    • This constructor is very similar to SimpleZone.fromBoxes(), but just returns a LessSimpleZone instead of a Zone, which has the additional features.

  2. LessSimpleZone.fromParts(parts: {Part}, queryOp: QueryOptions?): LessSimpleZone

    • This constructor is very special as its methods allows you to do precise point calculations (such as getting random points in the precise shape of each part, checking if a point is within the bounds of this zone without the use of checker parts, etc.)
      It took me very long to make this one work :sweat_smile:

  3. LessSimpleZone.fromBasePartsVertices(parts: {BasePart}, vertices: {Vector3}, queryOp: QueryOptions?): LessSimpleZone

    • Unlike LessSimpleZone.fromParts(), this constructor accepts MeshParts AND Parts!
      However, you do need to define your own vertices.

Methods
  1. LessSimpleZone:GetRandomPoint(): Vector3

    • This method does as it suggests, it returns a randomly placed point within the bounds of the LessSimpleZone.
      This method does not involve the use of checker parts, at all.

  2. LessSimpleZone:IsPointWithinZone(point: Vector3): boolean

    • This method returns a boolean indicating wether or not point is located within the bounds of this LessSimpleZone or not.
      Again, like LessSimpleZone:GetRandomPoint(), it is precise and does not involve the use of checker parts.

  3. LessSimpleZone:UpdateVolume(T...)

    • This method updates the volume of this LessSimpleZone.
      The arguments that it accepts varies depending on the type of LessSimpleZone, but it should tell you with the use of generic typechecking.

  4. LessSimpleZone:CombineWith(other: T)

    • This method simply combines this LessSimpleZone with other.
      May be useful if you wish to consolidate multiple LessSimpleZone volumes into one.
      Note that you cannot combine different types of LessSimpleZones together (for example cant combine LessSimpleZones made from boxes with ones made from parts, as they are fundamentally different.)
Flaws

Even though the .fromParts() constructor can provide precise point calculations for parts, it can only do so for 4 PartTypes (Ball, Block, Wedge, Cylinder).
For most purposes this should suffice, however if you wish to create custom vertex groups you can look at the LessSimpleZone.Vertices module which contains all of the vertex-defining information for parts, which you can use for your own point calculations.

Comparisons

GetRandomPoint comparison with ZonePlus (almost 100x faster!):



IsPointWithinZone comparison with ZonePlus (around 10x faster)

Geometry-precise generation of random points using vertices & barycentric coordinates (no checker parts!):

Download LessSimpleZone here →
LessSimpleZone.rbxm (21.4 KB)

Sorry if the writing seems sloppy or incomplete, I am EXTREMELy tired, have a great night.

19 Likes

This looks it could help with some tasks like a random drop or something of the sorts within a zones boundaries. Looks cool.

5 Likes

Yes, it also doesn’t involve the use of checker parts unlike ZonePlus which makes it faster too :slightly_smiling_face: (albeit more restricted to only 4 PartTypes)

3 Likes

Anyways, I’m heading off to sleep now. Hope people enjoy this module :slightly_smiling_face:

2 Likes

Nevermind I couldn’t sleep so I optimized the :IsPointWithinZone() method (used to take around 0.01s for 75 parts, now around 0.00003s-0.000004s which is around half-10th of ZonePlus)

Also I made it so that the methods are added directly to the created SimpleZone zone instead of using more metatables, this considerably sped up things :slight_smile:

1 Like

Performance test! (270 Part zones)


All done on the server, handles it like a champ!

1 Like

Also, I wanna apologize for the last time I argued with you in the replies section, I now realise that you’re right and ZonePlus isn’t meant for creating hundreds of zones at once, but rather creating it once for multiple zones. Hope you can forgive me :heart:

2 Likes

Ok really going to sleep now, goodbye

1 Like

I was over it when it started. I knew I was right anyway lol

1 Like

A more performance zone module was needed.
I think a good documentation and download link (except file) needed too.

It seems good rn. if I need to use zone module i will check this module.

3 Likes

Is it correct you cannot use a mesh part for a zone? If so any plans to have that possible?

2 Likes

Nope, with simple zone you can use mesh parts to create zones.

1 Like

Looks very well made, ill be using this in my project. Also I love how innovative the name is :joy:

2 Likes

With LessSimpleZone you indeed cant use meshparts for .fromParts(), this is because I cant predict what the vertices for it would be. However, you can modify the module and provide those vertices yourself and it should work :slightly_smiling_face:

1 Like

Hello! I use about 300 ish zones in my game and when converting from Zone Plus to your other module the performance was unusable, would this version you’ve created here solve this? I tried all of the functions in your other module but unfortunately had no luck. Not sure what ZonePlus does that yours doesn’t which would cause this.

1 Like

Hello, im pretty sure it’s because SimpleZone requires you to provide your own OverlapParams when calling :BindToHeartbeat(), whereas ZonePlus does it for you :slight_smile:

1 Like

Calling :BindToHeartbeat() with no OverlapParams means all detected parts will be accepted, which can get very laggy if you have alot of parts and zones.

This would make a lot of sense actually! If I’m doing it for a client region system simply whitelisting only the local player should solve this do you think?

1 Like

Yes, thatd solve it. charlimitahhh

Update: Reformatted the code to make it cleaner