theshizon Posted November 29, 2018 Share Posted November 29, 2018 Hi guys. I found some code on this game dev site function intersect(a, b) { return (a.minX <= b.maxX && a.maxX >= b.minX) && (a.minY <= b.maxY && a.maxY >= b.minY) && (a.minZ <= b.maxZ && a.maxZ >= b.minZ); } I need to recreate this in VEX for packed primitive bboxes. It doesn't have to be this method. I just need a really fast efficient way to detect a collision between moving bounding boxes and returning a 0 or a 1. Its in a scene thats going to be using the bboxes of a package containing many instances of trees, getting copied onto points on 2 colliding surfaces, hence the need to want to keep it packed for efficiency. Not sure how to fit this into vex. Any advice would be great Cheers Quote Link to comment Share on other sites More sharing options...
bunker Posted November 29, 2018 Share Posted November 29, 2018 you can use the getbbox vex function. Quote Link to comment Share on other sites More sharing options...
bunker Posted December 2, 2018 Share Posted December 2, 2018 (edited) here is an example, and HIP file: vector amin,amax; getbbox(0,amin,amax); vector bmin,bmax; getbbox(1,bmin,bmax); int intersect_(vector amin,amax,bmin,bmax) { return(amin.x <= bmax.x && amax.x >= bmin.x && amin.y <= bmax.y && amax.y >= bmin.y && amin.z <= bmax.z && amax.z >= bmin.z); } i@intersect_=intersect_(amin,amax,bmin,bmax); intersect is a reserved VEX function name, so I used intersect_ instead bunker_intersect_packed_001.hip Edited December 2, 2018 by bunker Quote Link to comment Share on other sites More sharing options...
acey195 Posted December 4, 2018 Share Posted December 4, 2018 Also, for object aligned boxes, I would generally loop over the objects, just use the Box SOP and then in VEX, do a intersect along the Normal (z), Up (y) vector and crossproduct(N, up) for the x axis, to get the scales. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.