Physics Optimization
Physics Optimization:
(See handy script at bottom of page)
NOTE: Setting prims to Phantom does not stop them from being calculated by the physics engine!
- The less the physics engine has to calculate, the smoother your region will perform. Creating clean low poly physics shapes for your complicated meshes is helpful, but you can also remove prim, mesh, and sculpted objects from the physics calculations completely.
- Physics Optimization also helps with Pathfinding. Pathfinding objects will only have to calculate to go around simple objects instead of complex builds, making everything work smoother and faster without sacrificing looks.
- The way to Physics Optimize is to link your complicated builds to a simple shape like a cube or cylinder. The simple shape should be the root prim and then set all child prims to PRIM_PHYSICS_SHAPE_NONE (in Edit > Features > Physics Shape Type)
Manual Instructions:
1. Build your object as you normally would
2. Create a simple shape, such as a cube or cylinder
3. Right click on your object, hold down shift and select the simple shape last
4. Press control and L to link it all (the simple shape should now be the root prim highlighted in yellow)
5. Tick edit linked parts
6. Hold down shift and de-select the root prim (the simple shape)
7. Under the edit menu, in the features tab, select physics shape type, and from the drop down menu select, physics type none. This will set all the child prims to none.
8. Select the root prim (the simple shape) and make it transparent.
Using the script below:
Or to make it even simpler just follow the above instructions 1 to 4 and then use the handy script attached below. Just drop it in the root prim (The new simple shape you just linked your build to)
Tip: Cubes are the cheapest shapes to use. Up to 14 cubes equates to the same value as one cut hollowed cube. Cylinders are also cheap, though not as cheap as cubes.
Here we linked a tree to a cube and set all child prims to physics shape type None (in Edit > Features > Physics Shape Type):
Collision:
When you are physics optimizing you really have to think of where you want the collision to be, because all the individual shapes set to physics none will act as though they are phantom. In this example we are using a tree. The actual original tree will be set to physics none and act as though it is phantom so an avatar will be able to walk through it. The root prim, which in this case is a cylinder, will be the only solid part of the whole linked set. By putting the root prim/simple shape around the tree trunk, you simulate a solid and avatars will collide with it.
In this example we used a cylinder, but we could have also used a stretched cube to achieve the same effect, and it would have cost slightly less.
For more complicated builds you can set certain parts to PRIM_PHYSICS_SHAPE_PRIM and others to PRIM_PHYSICS_SHAPE_NONE. The parts set to prim will act solid, and the parts set to physics shape type none will act as phantom.
More Examples:
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.
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.
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>
Back to Good_Building_Practices