Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Detecting if a Move Will Place an Object Underground

Morgana Aubret
Damaged Beyond Repair
Join date: 12 Jul 2005
Posts: 139
08-16-2005 13:51
When moving a non-physical object, is there a way to tell if the intended destination is underground? I am using llSetPos to move an item (in increments if the distance is over 10m). The object does not position correctly if it would end up underground, but stops partially imbedded at the surface. I can see why this is a good idea, but I would prefer to detect the error in advance and abort the move. Is there some way to do this?
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
08-16-2005 14:02
You can get ground level with llGround(vector offset) - mind, this is an offset from the prim's current position, so directly under the prim is llGround(ZERO_VECTOR).
_____________________
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
08-16-2005 14:14
Right, llGround(destination - llGetPos()) should give you the ground height of the location where you are setPos'ing to. If the value returned from llGround is greater then that of destination.z, then the destination is underground.

Keep in mind that this wont compensate for hills the object may encounter when moving to the destination, here's something that might help:
CODE

integer setPos(vector dest) {
while (llVecDist(dest, llGetPos()) > 0.1) {
vector prevPos = llGetPos();
llSetPos(dest);
if (prevPos == llGetPos()) {
// Object didnt move, probably stuck on ground.
return FALSE;
}
}
return TRUE;
}

This function will return FALSE if the object gets stuck while moving, TRUE if the movement was successful.
_____________________
October 3rd is the Day Against DRM (Digital Restrictions Management), learn more at http://www.defectivebydesign.org/what_is_drm
Morgana Aubret
Damaged Beyond Repair
Join date: 12 Jul 2005
Posts: 139
08-16-2005 17:12
I have not had problems with moving through hills. The object seems to go through them and come out the other side, but I'll have to do more tests. Thank you both!
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
08-17-2005 03:46
If the hill is small enough (across, height is irrelevant) it will bore straight through, llSetPos() effectively teleports it. If there's a wide enough hill it will still go through, but actually will slide over the hill, or more precisely tp to the right x,y co-ordinates and appear at ground level again, briefly.
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
08-17-2005 04:52
SetPos will not place the object too far underground, capping the altitude (z) to the ground height minus some constant, IIRC.


[Edit]
From http://secondlife.com/badgeo/wakka.php?wakka=llSetPos :
From: someone
llSetPos can never move an object below the ground; the object will be placed with its center at ground height.
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
a lost user
Join date: ?
Posts: ?
08-17-2005 07:33
Yes.. it is technically true:
From: someone
llSetPos can never move an object below the ground; the object will be placed with its center at ground height.


However.. this only works on the primary/parent prim. So if you had a linked set that was 30m high and the parent prim was on the top of that linked set, and was say... 0.1m thick (in height).. then that means all 29.95m of the rest of the object would be under the ground.

Try it.. it is very handy for hiding things under the ground when you need to do that, like sliding doors for instance.
Morgana Aubret
Damaged Beyond Repair
Join date: 12 Jul 2005
Posts: 139
08-17-2005 09:04
I need to use a bigger hill then. :) Thanks for the info on positioning - I missed that line in the wiki somehow, and the linking prims idea may prove very useful.