Bug in the physics engine with llApplyImpulse?
|
|
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
|
11-15-2006 10:33
I've been working on an uncaged version of my A-life (no hard-coded areas they can be in without dying) and think I found a bug with the physics engine. at a fairly frequent rate, my A-life will be orbited (instantly shot to over 1,000 Meters along a random direction) when the llApplyImpulse(...) command is triggered. Here's some parameters/facts about when this happens: llApplyImpulse(....) will use a vector no larger that <.05,.05,0.5> and no smaller than <-.05,-.05,-.05> llApplyImpulse does not trigger more than once every 1.5 seconds My objects appear to be orbited when an impulse is applied during a collision The objects get orbited in the same apparent timeframe as a griefing avatar orbiter- instant change in position; this is too fast for any kind of position checking script to halt the movement before it's too late. Countermeasures takenhere's a stripped down pseudo code I'm using for not applying impulse during collisions: integer collide;
default { state_entry() { llSetTimerEvent(2); } { timer() { if(collide==FALSE) { llApplyImpulse(calculated_vector,FALSE) } } } collision_start(integer num) { collide=TRUE; } collision_end(integer num) { collide=FALSE; } land_collision_start(vector pos) { collide=TRUE; } land_collision_end(vector pos) { collide=FALSE; } }
this has greately reduced the frequency at which my objects are orbited, but it still happens once in a long-while (about once every hour instead of every 5 minutes). my neighbors are starting to complain about my escaped A-life and I'd really like to get this fixed before they start filing ARs against me.
_____________________
My SLExchange shopTypos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not. The function is working perfectly fine. It's just not working the way you wanted it to work.
|
|
Suffugium Courier
Registered User
Join date: 27 Sep 2006
Posts: 0
|
11-15-2006 11:45
I'd be interested to know how "calculated_vector" is calculated. If you're dividing by something, perhaps that something ends up with a near-zero value and your calculated_vector balloons up bigger than you expect, or something similar.
I have a system of automated vehicles that exclusively uses llApplyImpulse in Suffugium, and I never notice any random stutters or orbitings.
|
|
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
|
11-15-2006 11:46
I'd be interested to know how "calculated_vector" is calculated. If you're dividing by something, perhaps that something ends up with a near-zero value and your calculated_vector balloons up bigger than you expect, or something similar.
I have a system of automated vehicles that exclusively uses llApplyImpulse in Suffugium, and I never notice any random stutters or orbitings.
|
|
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
|
11-15-2006 12:33
From: Lex Neva I'd be interested to know how "calculated_vector" is calculated. If you're dividing by something, perhaps that something ends up with a near-zero value and your calculated_vector balloons up bigger than you expect, or something similar.
I have a system of automated vehicles that exclusively uses llApplyImpulse in Suffugium, and I never notice any random stutters or orbitings. it uses feed-back from sensors to generate a direction vector, then uses llVectorNorm(generated_vector)*.05
_____________________
My SLExchange shopTypos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not. The function is working perfectly fine. It's just not working the way you wanted it to work.
|
|
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
|
11-16-2006 10:56
Okay, so theoretically, it should give a vector with magnitude 0.05, no matter what. Then again, if the original vector is really tiny, floating point error might just screw things up enough to make reality deviate from theory and produce a non-unit vector from llVecNorm. I'm not sure on that, as I've never seen it happen, but it wouldn't surprise me.
It might help to put in some tests on that calculated_vector to see if it's somehow managed to get large, and if it does, have it IM you. Try checking llVecMag() to see if it's significantly different from 0.05, and also check each component to see if its absolute value is much bigger than one would expect.
Of course, I could be completely wrong as to what's going on ;)
|
|
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
|
11-16-2006 20:48
From: Lex Neva Okay, so theoretically, it should give a vector with magnitude 0.05, no matter what. Then again, if the original vector is really tiny, floating point error might just screw things up enough to make reality deviate from theory and produce a non-unit vector from llVecNorm. I'm not sure on that, as I've never seen it happen, but it wouldn't surprise me. It might help to put in some tests on that calculated_vector to see if it's somehow managed to get large, and if it does, have it IM you. Try checking llVecMag() to see if it's significantly different from 0.05, and also check each component to see if its absolute value is much bigger than one would expect. Of course, I could be completely wrong as to what's going on  debugging code shows nothing out of my parameters for the size of the vector being used in llApplyImpulse.
_____________________
My SLExchange shopTypos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not. The function is working perfectly fine. It's just not working the way you wanted it to work.
|
|
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
|
Why does it turn back by llApplyImpulse?
11-20-2006 02:58
Hello there, I'm messing up my football shooting game. I made this script to see how llApplyImpulse worked. The ball catches avatar by senseor and aims by llLookAt. Then I wanted to hit it a long way by llApplyImpulse. It flew in the direction of my expectation but I got it turn back to the position where I hit immediately. Anyone helps? vector force = <-10, 0, -30>; vector offset;
offsetByAVSize(key Agent) { vector AVSize = llGetAgentSize(Agent); offset = <0.8, 0, 1.0 - AVSize.z>; }
default { state_entry() { llSensorRemove(); llOwnerSay("state default"); //Info for Debug llSetStatus(STATUS_PHYSICS, TRUE); } on_rez(integer reset) { llResetScript(); } collision_start(integer num_detected) { llSensorRemove(); lllSensorRepeat("","",AGENT, 2, PI, 0.2); } sensor(integer total_number) { offsetByAVSize(llDetectedKey(0)); vector pos = llDetectedPos(0); llMoveToTarget(pos+offset*llDetectedRot(0), 0.2); llLookAt(pos + <0, 0, offset.z>, .1 , 1); } no_sensor() { llSensorRemove(); } touch_start(integer total_number) { llSensorRemove(); llStopLookAt(); state shooting; } }
state shooting { state_entry() { llOwnerSay("state shooting"); //Info for debug llApplyImpulse(force, TRUE); llSleep(3); state default; } }
_____________________
 Seagel Neville 
|
|
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
|
Why does it turn back when it is hit by llApplyImpulse?
11-20-2006 03:10
Hello there, I'm messing up my football shooting game. I made this script to see how llApplyImpulse worked. The ball catches avatar by senseor and aims by llLookAt. Then I wanted to hit it a long way by llApplyImpulse. It flew in the direction of my expectation but I got it turn back to the position where I hit immediately. Anyone helps? vector force = <-10, 0, -30>; vector offset;
offsetByAVSize(key Agent) { vector AVSize = llGetAgentSize(Agent); offset = <0.8, 0, 1.0 - AVSize.z>; }
default { state_entry() { llSensorRemove(); llOwnerSay("state default"); //Info for Debug llSetStatus(STATUS_PHYSICS, TRUE); } on_rez(integer reset) { llResetScript(); } collision_start(integer num_detected) { llSensorRemove(); lllSensorRepeat("","",AGENT, 2, PI, 0.2); } sensor(integer total_number) { offsetByAVSize(llDetectedKey(0)); vector pos = llDetectedPos(0); llMoveToTarget(pos+offset*llDetectedRot(0), 0.2); llLookAt(pos + <0, 0, offset.z>, .1 , 1); } no_sensor() { llSensorRemove(); } touch_start(integer total_number) { llSensorRemove(); llStopLookAt(); state shooting; } }
state shooting { state_entry() { llOwnerSay("state shooting"); //Info for debug llApplyImpulse(force, TRUE); llSleep(3); state default; } }
_____________________
 Seagel Neville 
|