On Sat, 15 Jun 2002, Cale Dunlap wrote:
> I'm trying to make a water slash effect for my mod when a bullet traceline
> goes into a water entity. I'm having a world of trouble finding the entry
> point of the traceline. Any ideas? Someone said someone asked this before,
> but I was looking through the archives and was unable to find any reference
> to this problem. Please help, thanx.
>
> -Mazor
> http://nuke.shiftify.com/
>
Basically to a trace, and then keep cutting your distance in half using
UTIL_PointContents to figure out whenyou cross the water boundary.
This is what my code does, I'm sure you can easily modify it to suit your
needs. My traces always started IN water and I wanted to know where the
surface was along the bullet trace:
// Trace to the end of the streamer to see if
// there is architecture in the way.
UTIL_TraceLine(pev->origin, vecEnd, ignore_monsters, ENT(pev),&tr);
fDist = (tr.vecEndPos - pev->origin).Length();
// Now we need to find the distance to the water transition.
// (if there is one)
if (UTIL_PointContents(tr.vecEndPos) != CONTENTS_WATER)
{
Vector vecMin = pev->origin;
Vector vecMax = pev->origin + vecDir * fDist;
Vector vecMid;
float diff = fDist;
while (diff > 1.0)
{
vecMid = vecMin + (vecMax - vecMin).Normalize() *
diff / 2;
if (UTIL_PointContents(vecMid) ==
CONTENTS_WATER)
{
vecMin = vecMid;
}
else
{
vecMax = vecMid;
}
diff = (vecMax - vecMin).Length();
}
fDist = (vecMid - pev->origin).Length();
}
// Return new endpoint.
return pev->origin + vecDir * fDist;
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders