[Opensim-users] collision detection for attachments

Gwyneth Llewelyn gwyneth.llewelyn at gwynethllewelyn.net
Mon Jul 8 17:44:48 UTC 2013


Hiya,

Sorry for bumping up this thread. I have a similar issue, but my setup
prevents me from scripting every object in sight to detect collisions. Let
me explain why.

First, I'm trying to make my solution compatible across SL and OpenSim,
while developing most of the code in OpenSim: the theory is that if it
works in OpenSim, it should work even better in SL (based on the theory
that OpenSim only implements a subset of LSL – except for OS-specific
functions, of course). So, keeping things simple, and making them work in
OpenSim, should ensure compatibility with SL later on. That's the first
assumption.

The second one is that llCastRay() is, at best, tricky to find things, and,
at worst, useless. Here, neither SL nor OpenSim are "perfect". SL's
llCastRay() seems to give slightly better results, but they're "not as good
as advertised" — when the ray is being cast from a moving avatar, i.e. from
inside an attachment. (The alternative, using sensors, can be often worse
and has all the other known limitations).

The third assumption is that the world is full of unscripted objects, and
the scripts will have to deal with them all to have minimally accurate
"vision". So I cannot use dz's approach, which is to drop a script inside
each and every object in a 15,000-prim area (yes, my scripts need to
navigate across all that), and expect them to send collision events via
llSay(). It's simply unfeasible. There is an old Indian Buddhist saying
that goes, "If the roads hurt your feet, the solution is not to wrap the
whole world with leather to make all surfaces soft, because that's
impossible; instead, wrap just a little bit of leather across your feet,
and you can walk all roads without hurting yourself". A very good
similarity applies to this case, IMHO: it's a bit pointless to make sure
*all* the world is scripted for collisions, when you just need to test
collisions on one's attachments.

So what I'm doing is a mixed approach. First, I cast a ray, to get a list
of what OpenSim (or SL) _thinks_ is ahead of the avatar. But sometimes the
ray will just send back wrong/incomplete information, and the avatar — in
the case where no human is behind it, of course — hits a wall. In that
case, I wish the attachment to detect the collision and report back to the
system, and flag an exception — we thought the way was clear, but it isn't.
Also, this approach means that the script doesn't need to be sending rays
in very short time frames — just once in a while, assuming most of the
environment will remain static, and deal with exceptions (or cast new
rays!) if it starts bumping into things.

This works well enough in SL, but apparently not in OpenSim: apparently,
without any special tricks, it seems impossible to get collision events in
an attachment to work (at least on 0.7.5 Dev). Why?

If there are any special tricks to get this working, what are they?

Will switching to 0.7.6 Dev make any difference? (As far as I can see on
the Mantis and/or searching via Google, nobody seems to be mentioning
this). Will this be implemented in BulletPhysics? (I'm not even sure if
BulletPhysics already works under Linux these days...)

I'm also looking for an alternative using libopenmetaverse. The simulator
definitely sends *some* messages to the viewer when there is a collision
with the avatar. However, it's not that obvious how to catch the reverse
situation: when the avatar collides with an object :-(

Any further suggestions are most welcome!

   - Gwyn


On 24 March 2013 16:11, dz <dz at bitzend.net> wrote:

> I would have to qualify my answer, given your response..
>
> The NPC collisions I deal with involve avatars bumping into various
> objects in the course of them walking and running about in a region.  The
> majority of my sensors are at street intersections where I can make the
> NPC to react to red/green lights, or send them off in another direction.  I
> also use them to trigger pause and reach animations for doors,  or
> sometimes trigger reactions when encountering "Special" NPC's.  The speed
> of the moving avatar is much lower than the speed of a bullet, and the
> solution I use limits the number of objects in a sim that cause reactions.
> Too many scripted objects / simultaneous collisions can be a serious
> performance issue.
>
> I have not attempted to apply this design to an object like a bullet.   My
> understanding is that best SL solution to that problem it to use the
> orientation of the gun ( or gun sight ) and location of the target to
> pre-determine if the bullet will hit/miss.  Scripters in SL are using the
> llCastRay function to perform this intersection determination.  [ I cant
> say if or when llRayCast is/will be implemented in OpenSim, or what its
> performance would be like compared to SL.]  The bullets are still
> expended,   but in order to minimize the accumulation of spent ammo, the
> bullets just "fly and die", removing themselves after a brief period of
> time.   In that instance,  you can certainly have the GUN broadcast a HIT
> message to the avatar, but I don't think its a good plan to script bullets
> to be generating and processing collision events.
>
>
>
> D
>
> _______________________________________________
> Opensim-users mailing list
> Opensim-users at lists.berlios.de
> https://lists.berlios.de/mailman/listinfo/opensim-users
>



-- 
"I'm not building a game. I'm building a new country."
  -- Philip "Linden" Rosedale, interview to Wired, 2004-05-08
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://opensimulator.org/pipermail/opensim-users/attachments/20130708/6728dee5/attachment.html>


More information about the Opensim-users mailing list