Physics Test

Category:Test Scripts
== Purpose ==
Test measurable aspects of the physics engine and verify they remain consistent.
== Consistency test ==
=== Setup ===
* Wear the avatar from Library > Clothing > Boy Next Door. Avatar mass is determined by shape size, so we need to start with a known quantity.
=== Avatar ===
* walk speed
** Add the following "Report Velocity script" to a box then wear the box.
** Walk your avatar on level terrain and verify the velocity is ~3.2
//Report Velocity
default
{
 state_entry()
 {
 llSetTimerEvent(0.5);
 }
 timer()
 {
 if (llGetAttached())
 {
 float velocity = llVecMag(llGetVel());
 if (velocity) llOwnerSay((string)velocity);
 }
 }
}
* run speed
** Wear the "Report Velocity" object from the previous test.
** Run your avatar around on level terrain and verify the velocity is ~5.13
* fly speed
** Wear the "Report Velocity" object.
** Fly your avatar straight and level and verify the velocity is ~16.0
* Add the following "Measure jump height script" to a box then wear the box.
** Jump and verify the reported jump height is ~3.98m
//Measure jump height
vector x;
float starting_height;
float highest_height;
float current_height;
integer started;
default
{
 state_entry()
 {
 llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS);
 llTakeControls(CONTROL_UP, 1, 1);
 llOwnerSay("ready");
 }
 attach(key id)
 {
 llResetScript();
 }
 control(key id, integer level, integer edge)
 {
 if (started == 0)
 {
 x = llGetPos();
 starting_height = x.z;
 llSetTimerEvent(0.05);
 llResetTime(); 
 highest_height = 0.0;
 started = 1;
 }
 }
 timer()
 {
 x = llGetPos();
 current_height = x.z;
 if (current_height > highest_height)
 {
 highest_height = current_height;
 }
 if (llGetTime() > 5.0)
 {
 llSetTimerEvent(0.0);
 started = 0;
 llSay(0, "Jump height was: "+(string)(highest_height - starting_height));
 }
 }
}
* jump distance
** Add the following script to a box then wear the box.
** Jump while walking forward and verify the reported jump distance is between 7.3 and 7.5m
//Measure Jump script
vector jump_start_position;
float jump_start_time;
default
{
 land_collision_end(vector start_pos)
 {
 jump_start_position = start_pos;
 jump_start_time = llGetTime();
 }
 land_collision_start(vector end_pos)
 {
 llSay(0, "jump distance: "+ (string)llVecDist(jump_start_position,end_pos)+", hang time: "+(string)(llGetTime() - jump_start_time));
 }
}
* hang time
** Use the Measure Jump object again
** Jump while walking forward and verify the hang time is ~1.6s
* Avatar Mass 
** Add the following script to a box then wear the box.
** Click the box and verify the mass = 1.735026
//Measure mass
default
{
 touch_start(integer total_number)
 {
 llSay(0, "Mass: "+(string)llGetMass());
 }
}
* friction when walking on steep terrain
** Verify the avatar can walk up steep terrain, such as the nearly vertical hill at http://maps.secondlife.com/secondlife/Bug%20Island/240/9/31
* friction when walking on objects
** Wear the "Report Velocity" object from the above tests.
** Create a box and scale it up to 10x10x1m box.
** Verify that the walk and run speeds match that of when walking and running on terrain.
* Standing friction on objects
** Create a box and scale it up to 10x10x10m. Color the top face red.
** Rotate the box to X=0,Y=50,Z=0
** Verify your avatar can stand on the top (red) face without sliding off the box.
** Rotate the box to X=0,Y=65,Z=0
** Verify your avatar now slides off the top (red) face of the box.
* Avatar cannot walk up a vertical face of a prim.
** Create a box and scale it up to 10x10x10m. Leave the rotation of the box default (X=0,Y=0,Z=0).
** Attempt to walk up each side of the box.
** Verify the avatar cannot walk up any face of the box.
* Avatar can walk up short steps, and is not able to walk up high steps.
** Create a 10x10x2m box to use as a platform.
** Create a 2x2x0.75m box on the platform.
** Verify that your avatar is unable to walk over the box.
** Scale the height of the box down to 0.73m. Take the box and rez the box on the platform again so it's flush with the platform.
** Verify that your avatar is now able to walk over the box.
=== vehicle - Kart ===
* turning diameter
** Rez the "Kart 1.0" from My Inventory/Library/Objects.
** Add the following "Vehicle turning diameter" script to a box then wear the box.
** Sit in the Kart and drive in a circle on level ground.
** Verify the turning diameter is 47 ±1 m
//Vehicle turning diameter
rotation rotation_start;
rotation rotation_current;
vector position_start;
vector position_current;
default
{
 state_entry()
 {
 llOwnerSay("ready");
 llSetTimerEvent(0.1);
 rotation_start = llGetRot();
 position_start = llGetPos();
 }
 timer()
 {
 rotation_current = llGetRot();
 position_current = llGetPos();
 float x = llAngleBetween(rotation_current, rotation_start);
// llOwnerSay((string)x);
 if (llFabs(x - PI) < 0.1)
 {
 llOwnerSay("diameter: "+ (string)llVecDist(position_start, position_current)+"m");
 rotation_start = rotation_current;
 position_start = position_current;
 }
 }
}
* maximum speed
** Wear a box that has the "Report Velocity" script from above.
** Drive the Kart and verify the maximum speed ~43
* coast-to-stop time
** Drive the Kart at the maximum speed, then count how long it takes to coast to a stop.
** Verify the Kart stops in ~5 seconds.
* mass
** Add the "Measure mass" script from above to the Kart.
** Click the Kart and verify it reports "Mass: 9.995405"
=== energy ===
* Skip this energy section for now.
** bounce pad: (object with llPush)
** energy lost when launching an avatar (or itself)
** time to recover energy
=== buoyancy ===
* maximum size of an object that can stay buoyant.
** Create a 4x4x4m box and add the following script.
** Set the box Physical
** Verify you can push the box around and it will float above the ground and the energy will not drop to 0.
** Change the box size to 4x4x5m box.
** Push the box around and verify it's energy drops to 0.
default
{
 state_entry()
 {
 llSetBuoyancy(1);
 llSetTimerEvent(0.1);
 }
 timer()
 {
 llSetText("energy = "+(string)llGetEnergy(), <0,0,1>, 1);
 }
}
* verify functionality of an object with buoyancy of 0.
** Modify the above script and change the llSetBuoyancy to 0.
** Create another box and set it physical.
** Select and lift both boxes about 50m above the ground, then deselect them.
** Verify both boxes hit the ground at the same time.
* verify functionality of an object with buoyancy of -1.
** Modify the above script and change the llSetBuoyancy to -1.
** Select and lift both boxes about 50m above the ground, then deselect them.
** Verify the box with the script hits the ground first.
=== collisions ===
* (soon) collision tolerance should be 0m
** Verify that a physical box rests directly on the ground. (no longer has a 0.1m gap)
** Verify that a physical box rests directly on a non-physical box. (no longer has a 0.1m gap)
** Verify that a physical box rests directly on a physical box. (no longer has a 0.1m gap)
* (soon) there will be a 5cm gap on any non-convex prim that is set physical
** Verify there is a small gap between a physical torus resting on box.
=== Center of Mass ===
* CoM correct after linking
** Create a red sphere and a blue sphere and link them together.
** Make the linked set physical.
** Lift the object then rotate and drop it so the red sphere hits the ground before the other.
** Verify that the object comes to rest with both spheres touching the ground.
** Lift the object then rotate and drop it so the blue sphere hits the ground before the other.
** Verify that the object comes to rest with both spheres touching the ground.
* CoM correct after unlinking
** Unlink the 2 spheres from the last test.
** Bump the spheres and verify they roll in a straight line without wobbling.
----
== legacy test ==
[PHYSICSTEST]
[VERSION] 0.2
[LENGTH] 00:15
[TESTERS] 1
[OVERVIEW] This test has been designed to the basic functionality of pinned objects 
(a.k.a. "non-physical" objects), and non-pinned objects (a.k.a. "physical" objects).
[SETUP] Tester must be in an area where building is enabled.
[*]
[Linked Objects]
[0010] Make a complicated linked object with more than three pinned primitives, each piece 
with a non-trivial rotation, and preferably not all the same shape:
[0010.0010] Unlink and link the collection a few times... the primitives should not change 
position/rotation between link/unlink cycles.
[NOTE] Notes are also recognized!
[INV] Inventory
[0010.0020] Duplicate the linked object. Did it copy correctly?
[0010.0030] Unpin the linked object and use Grab to throw it around. Does it collide 
correctly?
[0010.0040] Throw the object across the region boundary. Did it cross correctly?
[*]
[Simple Grab]
[0020] Find a relatively flat location near a region boundary. Create two single-primitive 
objects, one pinned and one non-pinned.
[0020.0010] Does Grab move each one in the X-Y plane?
[0020.0020] Does CTRL-Grab move each one in the LeftRight??-Z plane?
[0020.0030] Does SHIFT-CTRL-Grab rotate each object?
[0020.0040] Can Grab be used to move each one across the region boundary?
[0020.0050] Can you Grab each object when they are across the boundary from you
[*]
[Colliding Grab]
[0030] Make a floor, add two walls, and create a single-primitive pinned object near the 
middle of the floor.
[0030.0010] Can you Grab the pinned object and move it about the floor?
[0030.0020] Create a new object on the floor and make it non-pinned.
[0030.0020.0010] Try to Grab the object and move it beyond the wall; expected behavior is 
that it will lightly bounce against the wall.
[0030.0020.0020] Do collisions generate sounds and particle systems?
[0030.0020.0030] The object should never be able to interpenetrate or tunnel through the wall.
[0030.0020.0040] Use Grab to collide the non-pinned object against the pinned object that 
was being grabbed earlier. If the Grabbed object rotates, it should rotate very slowly as if it were being slowed down by molasses.
[*]
[Interpenetration Rules]
[0060] Make two pinned objects and two non-pinned.
[0060.0010] Try to use the build-mode move tool to position one pinned object into a state 
of interpenetration with the other pinned object. The operation should succeed.
[0060.0020] Try to move the same pinned object into a state of interpenetration with one of the 
non-pinned objects. While moving the pinned object in edit mode, it should interpenetrate, 
but as soon as you release the mouse, the objects should move away from one another till there is no
interpenetration.
[0060.0030] Move the pinned object back into interpenetration with the other pinned 
object, then try to unpin it. The objects should move away from one another till there is no
interpenetration.
[*]
[NOTE] Don't forget to clean up your test area when finished!
Category:QA Portal
Category:Quality Assurance