Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Accurate collision detection...

Moira Willenov
Registered User
Join date: 1 Jul 2008
Posts: 15
06-28-2009 15:58
Ok, here's the deal. I have a target and i want it to rez a tiny prim at the precise collision point that another object hits. Now this does not seem to work with llDetectedPos() as the object rezzed always appears a slight distance away from the skin of the object. How would i calculate a new position for the rezzed "Bullet Hole" that would be right against the surface of the prim struck, no matter the shape or size of the object? Would this need to be a calculation based on velocity? Any help here would be appreciated. :)
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
06-28-2009 18:55
you'll find that velocity calculation isn't going to be very helpful, since by the time you get the information, it'll show the collided object in a new heading...

you CAN generalize and calculate the distance from the collision point to your surface, and then rez there... it won't be perfect and gets worse with angle, but considering the distance involved it's pretty close.

essentially you replace the axis position on the side that got collided with your own precalculated surface distance as a for instance take a default zero_rotation cube, inpacted from the top, and use the position you got from the impacting object, but replace the z value with a precalulated z of the objects center to it's top.... for rotated objects you can apply the inverse of your objects rotation to the position returned before calculating this, and then reapply you objects rotation.

it's all a PITA.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
06-29-2009 05:38
Also I believe that, with the exception of low-lag sims, that the physics calculations are only so precise anyway, meaning few collisions actually occur with real contact against the object.

So in a lot of cases the projectile /will/ collide a short distance from the target object.
_____________________
Computer (Mac Pro):
2 x Quad Core 3.2ghz Xeon
10gb DDR2 800mhz FB-DIMMS
4 x 750gb, 32mb cache hard-drives (RAID-0/striped)
NVidia GeForce 8800GT (512mb)
Moira Willenov
Registered User
Join date: 1 Jul 2008
Posts: 15
Damn...
06-29-2009 12:16
Ok thanks all. :P i figured my math was right on the mark. :)