Comparing positions and sizes of 2 3D objects. (lua)
I've got two 3d objects. They are both rectangular prisims. I need to check to see if the two objects are intersecting to any degree. I know a slow and annoying way (checking the left, right, etc.). I just need to be able to tell when the the object is inside of the other.
Tha开发者_运维技巧nks if you can! Any psuedo code is appreciated!
I'm not sure I understand what you believe to be the 'slow and annoying way', but it sounds like a reasonable approach to test each face against the bounds of the other object. If the two prisms are oriented arbitrarily in space that's really not a wrong thing to do. However, you can do a quick and dirty check before that to see if its worth the expense by describing a spherical bounding box (ball) around the prism and doing a simple distance check first - if the two bounding boxes aren't touching (easily determined by calculating distance of separation and summing the two radii of the two bounds) then you don't have to check for orientation dependent intersections.
精彩评论