#GetPartBoundsInBox, How does it work?

1 messages · Page 1 of 1 (latest)

late raft
#

and is there a better way to do this

function Octree:SubDivide()
    local HalfSize = self.Size / 2
    local RootPosition = self.Center + Vector3.new(HalfSize / 2, HalfSize / 2, HalfSize / 2)
    self.Nodes[1] = self.New(RootPosition - Vector3.new(0, 0, 0), HalfSize)
    self.Nodes[2] = self.New(RootPosition - Vector3.new(HalfSize, 0, 0), HalfSize)
    self.Nodes[3] = self.New(RootPosition - Vector3.new(0, HalfSize, 0), HalfSize)
    self.Nodes[4] = self.New(RootPosition - Vector3.new(0, 0, HalfSize), HalfSize)
    self.Nodes[5] = self.New(RootPosition - Vector3.new(HalfSize, HalfSize, 0), HalfSize)
    self.Nodes[6] = self.New(RootPosition - Vector3.new(0, HalfSize, HalfSize), HalfSize)
    self.Nodes[7] = self.New(RootPosition - Vector3.new(HalfSize, 0, HalfSize), HalfSize)
    self.Nodes[8] = self.New(RootPosition - Vector3.new(HalfSize, HalfSize, HalfSize), HalfSize)
    self.Divided = true
end
#

ill sleep now

spiral rapids
#

needs something like propertychangedsignal("cframe") on every instance, or you can do it the naive way and put a part in every region with .touched and .touchended connections

late raft
#

aw

spiral rapids
#

the point of the partitioning is to know what is in each partition, and update movements of things, without needing to raycast, instead only comparing position

spiral rapids
#

and it can depend on how they move i.e a humanoid would know when to check in at all times, but a part subject to physics would not

late raft
#

hmmmm

spiral rapids
#

and some things you may not want to track, i.e physical projectiles

#

aka you should already have a variable with the objects before you get to this function

late raft
#

yea well I kinda expected that

#

aaaaaaaaaaaaaaaaaaaaaaaaaa

#

this is so ass

spiral rapids
#

and the ObjectsInRegion() is a one-liner that returns this variable. the rest of your code deals with keeping this variable up to date when things move

late raft
#

yea

spiral rapids
late raft
#

no idea what that is

#

but okay

spiral rapids
#

it's how pathfinding works ;o

#

it maps all walkable area

late raft
#

oh

#

yeai think ive heard of it

spiral rapids
#

why not roblox expose this map so we can read it? we may never know 💀

late raft
#
function Octree:Subdivide()
    local HalfSize = self.Size / 2
    local Quarter = HalfSize / 2

    local Offsets = {
        Vector3.new(-Quarter, -Quarter, -Quarter),
        Vector3.new( Quarter, -Quarter, -Quarter),
        Vector3.new(-Quarter,  Quarter, -Quarter),
        Vector3.new( Quarter,  Quarter, -Quarter),
        Vector3.new(-Quarter, -Quarter,  Quarter),
        Vector3.new( Quarter, -Quarter,  Quarter),
        Vector3.new(-Quarter,  Quarter,  Quarter),
        Vector3.new( Quarter,  Quarter,  Quarter),
    }

    for i = 1, 8 do
        local Offset = Offsets[i]
        local ChildCenter = self.Center + Offset
        self.Nodes[i] = Octree.New(ChildCenter, HalfSize)
    end
end

skidGPT told me to do it like this but idk it takes more lines and feels gay

spiral rapids
spiral rapids
late raft
#

its fine

#

?

spiral rapids
#

"better" doesnt have much meaning here

late raft
#

ok so its fine

#

?

spiral rapids
#

don't sweat the fractions of a fraction of a frame, it's not like how you use this function will change if you ever do change its technique

late raft
#

like not manually

#

but yk

#

but uh anyway

#

i have to go

#

tysm