Difference between revisions of "Good Building Practices"

From Second Life Wiki
Jump to navigation Jump to search
(Replaced content with "== Optimization == <div style="padding: 0.5em"> * '''Physics Optimization''' - Not everything needs physics, learn how to add the least load necessary to the physics engi…")
Line 1: Line 1:
Physics Optimization:
== Optimization ==
<div style="padding: 0.5em">
* '''[[Physics Optimization]]''' - Not everything needs physics, learn how to add the least load necessary to the physics engine.


(See handy script at bottom of page)
</div>
 
</div>
'''NOTE: Setting prims to Phantom does not stop them from being calculated by the physics engine!'''
<div id="box">
 
The less the physics engine has to calculate, the smoother your region will perform.  Creating clean low poly physics shapes for your meshes is helpful, but you can also remove prim, mesh, and sculpted objects from the physics calculations completely.
 
<gallery>
File:Physics_trees.jpg|Two trees set to Prim
File:Physics_shapes.jpg|Physical shape of trees
File:Physics_in_navmesh.jpg|Results in the navmesh
</gallery>
 
Link your complicated geometry to simple shapes. Here we linked to a cube and set all child prims to physics shape type None (in Edit > Features > Physics Shape Type):
 
<gallery>
File:Physics_no_physics.jpg|No physics on trees
File:Physics_set_to_none.jpg|Navmesh sees only cube set to Prim
</gallery>
 
To simulate a physics shape and keep avatars from walking through your optimized object, just add physics where it's needed.
 
<gallery>
File:Physics_add_physics.jpg|Adding physics
File:Physics_007.jpg|As seen by physics engine
File:Physics_added_physics_in_navmesh.jpg|As seen by the navmesh
</gallery>
 
----
Here is another example scenario.  This is a sculpted prim fence.  The physics shape is not as clean as it could be, and the edges don't cover all edges of the fence itself.  To fix it, I created a cube physics shape, linked the fence to the cube with the cube as the root prim, and set the fence to Physics Shape Type: None.  As you can see, the resulting physics shape is lower in polygons and better covers the fence area.
<gallery>
File:Sculpty_optimization_001.jpg|Sculpted fence physics shape
File:Sculpty_optimization_002.jpg|Adding cube physics shape
File:Sculpty_optimization_003.jpg|Final Static Object physics shape
</gallery>
 
This is a tree comprised of many sculpted pieces.  Keep in mind that the physics engine needs to calculate every part of the physics shape in the second picture.  Here I created a cylinder for the physics shape to fit on the bottom of the tree trunk.  By linking the cylinder to the tree, and setting the tree to physics shape none, I have a much cleaner static object. 
<gallery>
File:Sculpty_optimization_004_001.jpg|Sculpted Tree
File:Sculpty_optimization_004_002.jpg|Un-optimized sculpted tree physics shape
File:Sculpty_optimization_004_003.jpg|Adding simplified physics to tree, setting to root
File:Sculpty_optimization_004_004.jpg|Final tree physics set to static obstacle
</gallery>
 
Use the following script to set all child prims to None.  Be sure to check what physics are needed for your linkset prior to using, and/or add a simple cube as the root prim.
<lsl>
default
{
    state_entry()
    {
        llShout(0, "Setting all child prims to PRIM_PHYSICS_SHAPE_NONE");
        llSetLinkPrimitiveParamsFast(LINK_ALL_CHILDREN, [PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_NONE]);
        llRemoveInventory(llGetScriptName());
    }
}
</lsl>

Revision as of 12:16, 9 April 2012

Optimization

  • Physics Optimization - Not everything needs physics, learn how to add the least load necessary to the physics engine.