DragoniteSpam-GameMaker-Tutorials / 3DCollisions

Native 3D Collisions in GameMaker!
Apache License 2.0
15 stars 4 forks source link

Colworld only works with spheres checking against Oriented bounding boxes #8

Open EvanSkiStudios opened 1 month ago

EvanSkiStudios commented 1 month ago

For a few weeks I've been trying to get the latest of this to work with my project all my objects currently are AABB

but no collisions at all are detected in the col world

I set up the col world using the exact same lines of code from the 3DCollisionTestWorld except im using the octree instead

var bounds = NewColAABBFromMinMax(new Vector3(-2000, -2000, -25), new Vector3(2000, 2000, 250));
var octree = new ColWorldOctree(bounds, 3);
collision_world = new ColWorld(octree);

for reference my player is like so

shape = NewColAABBFromMinMax(new Vector3(self.x - 4, self.y - 4, 0), new Vector3(self.x + 4, self.y + 4, 16));
player_object = new ColObject(shape, self.id, 1, 1);
collision_world.Add(player_object);

and my wall objects are likewise

shape = NewColAABBFromMinMax(
    new Vector3(self.x, self.y, 0),
    new Vector3(
    self.x + 32,
    self.y + 32,
    32
);
wall_object = new ColObject(shape, self.id, 1, 1);
collision_world.Add(wall_object);

and the player check is as simple as

if (collision_world.CheckObject(player_object)){
  show_message("Hello world");  
}

and I get nothing

it wasnt until changing the player to a sphere and the walls to OBBs that any collision was registered at all

Sorry if this isnt the correct place to report issues but i didnt know of another way of brining it to your attention i can provide any other info if necessary as well

thanks

DragoniteSpam commented 1 month ago

oh that's exciting. i'll try to remember to deal with this tomorrow but if you don't hear from me in a few days it's probably safe to assume i forgot and you should bother me again

EvanSkiStudios commented 4 weeks ago

Heyo so a little bump and update

I noticed that in my copy of the 3DCollisions, I did have the col world functions so I went through and used them and It works with the AABB

however, I don't know what "version" of your scripts I have, I can provide them if you want to take a look if it helps narrow it down, I don't have the camera frustum scripts in my copy

but some code change between the copy I have in my project and the latest has the bug in it, as the latest still doesn't work for me

EvanSkiStudios commented 3 weeks ago

So i think I have found the issue I updated the scripts to this commit https://github.com/DragoniteSpam-GameMaker-Tutorials/3DCollisions/tree/c7137118b40d2934916b48feabd6b580d64ad180

and everything works fine I think the issue lies in how a colworld is created as the scripts before the colworld taking an Octree, Quadtree, or Spatial Hash, will work

Im unsure if this is a bug or I'm just missing some critical part of the new setup which is the reason my colworld stops detecting any collisions

DragoniteSpam commented 2 weeks ago

okay, as promised I forgot about this for a few weeks - which file is the offending code in? that's one of the "optimization" commits which doesn't really narrow it down much

EvanSkiStudios commented 2 weeks ago

All good!

I think the issue is in ColWorld and how it makes a world out of the defined shape, but im not 100% sure on that