Colision detection cycle

Hey everyone. (Merry Christmas btw)
Just a simple question. I am working on collision detection and I am not sure about some things.

  1. When I have a level with exact number of object, do I have to run the cycle to check if the char is not in the object for the whole level? I guess so but isn’t it too bad for performance?
  2. When I want to move my char according to the surface, is it possible to make the surface from a lot of vertexes and then just find the nearest and compare it’s Y value with Y value of foot (or some kind of static vertex that is not influenced by animations and is somewhere in the foots area) and then just move the char according to that? Or is there another common way how to do that?

Thanks and have a nice day.

I am not an expert on the subject and I am reaserching on that too, but you are not suppose to check every object cause as you said is slow. You can do grouping, and insted of cheacking for real object(which can be made of many triangles) you represent it by a sphere, why because a sphere testing is simple for example, because sphere can be represented as a point(the sphere center) and a radious so if you need to test to see if a point(x,y,z) is touching it is as simple as substrating the the center point of a sphere with the point your are testing like

depth= magnitude(sphereCenterpoint-testpoint)-radious

now if depth(penetration) is how much the point is inside meaning is overlaping it so the object are more likely to be touching.

because of this simple test is better to sorround object like your character, tree etc in simple ones as sphere, en then do a more fine testing. Now about the grouping you if you every object is sorround by a sphere volume, the if you have a char that chair is inside the sphevolume of the room as any other object in the room and as there are many more rooms in a house you character volume(the sphere volume) is only tested on against the sphere of the room, if the test pass is because you character is inside that room, then you test for object on that room the test passed, not the other one it did not pass meaning you are not doing test with every object of a house, just the one closer to your character.

I hope that is clear this time of testing is call bounding volume hierarchy, after you know when to object collide the is a metter of separeting it, and you can do that by pulling the the object back by the depth calculated avobe the only thing missing is the direction where to pull since depth is a float, the direction is calculatete as
dir = (sphereCenterpoint-testpoint)

Then normalize dir and multiplie it by sepDist=dir*depth;

I hope that is clear for you.