Instead of spam the same hard question like my previous one that Is difficult to get a minimum verifiable example for, I have decided to rework my path-finding and I can fix a lot of my issues with an oct-tree, not a true one but rather just subdividing my world into 8 or however many i specific in the function as this is all thats needed.
I already know what i need to do the stage after this, but I'm a not sure the best way to approach the subdivision so i get the right vector points of the subdivided cubes.
div = the number of cubes I want to create.
If I already have my 8 points,
worldspace(Vector3 origind, float sized)
{
// face1
ca = Vector3{ origin.GetX() + sized,origin.GetY() + sized, origin.GetZ() - sized };
cb = Vector3{ origin.GetX() + sized,origin.GetY() - sized, origin.GetZ() - sized };
//-----------------------------------------------------------------------------
cc = Vector3{ origin.GetX() - sized,origin.GetY() - sized, origin.GetZ() - sized };
cd = Vector3{ origin.GetX() - sized,origin.GetY() + sized, origin.GetZ() - sized };
// face 2
ce = Vector3{ origin.GetX() + sized,origin.GetY() + sized, origin.GetZ() + sized };
cf = Vector3{ origin.GetX() + sized,origin.GetY() - sized, origin.GetZ() + sized };
//-----------------------------------------------------------------------------
cg = Vector3{ origin.GetX() - sized,origin.GetY() - sized, origin.GetZ() + sized };
ch = Vector3{ origin.GetX() - sized,origin.GetY() + sized, origin.GetZ() + sized };
};
~worldspace();
I can define my worldspace as worldspace(0,0,0,25) so thats a cube of 25 units, but then I want to divide it in the most efficient way into 8 = cubes lets say or so and make them into a vector.
I'd like the function to be able to specify how many subdivisions i want, I don't want a dynamic one, so I think. So I'm thinking I could do something along the lines of
semi pseudocode
createoct(div)
int divisions = div
for (int i = 1; i =< div; i++)
{
dist of ca to cb / div ?
store the new point
do the same for the other points ?
}
Am I going about this the right way ? what would be the best way to calculate the subdivisions and store their 4 seperate points as one object ? perhaps a new class ?
divrepresent? The number of divisions per side, or the number of smaller cubes you want it to end up with? \$\endgroup\$