Changes between Initial Version and Version 1 of PerformanceAndOptimization

2011-09-17 12:50:12 (10 years ago)



  • PerformanceAndOptimization

    v1 v1  
     1{{{ #!Markdown 
     3# Performance and optimization 
     5I care about the objects being passed as reference to the functions in order to avoid copying objects. Feel free to check out the main scripts ([CarInput](wiki:CarInput), [CarControl](wiki:CarControl), [CarWheel](wiki:CarWheel), and [CarWheelFriction](wiki:CarWheelFriction)) and please let me know if you find something that could be optimized. 
     7But there are operations that require entire objects to be created and deleted and cannot be optimized (or I don't know how to do it). Skidmarks, SkidSmoke (both controlled from [CarVisuals](wiki:CarVisuals)) and [CarDamage](wiki:CarDamage) are the top memory wasters.  
     9- Deforming the mesh in [CarDamage](wiki:CarDamage) requires to create a temporal copy of the entire vertex array of the 3D model, modify the copy, then reassign it to the Mesh Filter. Deforming the collider requires an entire temporal mesh (vertices + triangles) to be created and disposed. 
     10- The Skidmarks are generated as a single mesh containing all the visible skidmarks for the scene (_Hierarchy: World > Skidmarks_). Each time a new skidmark is generated, the entire mesh is disposed and re-generated. Note that this is the skidmarks script from the Unity's Car Tutorial with a few minor adjustments. You can adjust the maximum mesh size for the skidmarks with the property __MaxMarks__. 
     11- The smoke is just a particle emmiter (_Hierarchy: World > Skidmarks > SkidSmoke_), so it's up to Unity's particle system. Particles are generated and disposed as they go through their life cycle. You can adjust the number of particles with the properties __MinEmission__ and __MaxEmission__, and their duration in seconds with __MinEnery__ and __MaxEnergy__. 
     13## Optimizing the friction curves 
     15[CarControl](wiki:CarControl) has a property __optimized__ which controls the respective _optimized_ properties at each [CarWheel](wiki:CarWheel). 
     17- Keep _optimized_ DISABLED for fine-tuning the friction curves in real-time at [CarControl](wiki:CarControl) (_ForwardWheelFriction_ and _SidewaysWheelFriction_). The curve's internal parameters are recalculated on each cycle (FixedUpdate) allowing real-time modifications from the editor. 
     18- ENABLE _optimized_ for releasing the project, or when the friction curves don't require further modifications. The internal parameters are calculated once on start and then reused. 
     20## GUI objects 
     22__[CarInput](wiki:CarInput)__ displays the vehicle's dashboard. You can disable it by setting the property __guiEnabled__ to false. 
     24__[CameraControl](wiki:CameraControl)__ references the GUITexture objects used for the vehicle's mirrors. Set __showMirrors__ to false for disabling all processing regarding the mirrors. You could also delete the GUITexture objects (children of MAIN), the mirror cameras (actually available at the Bus only), and the RenderTexture assets where the mirrors are rendered (located at _Assets \ EdyVehiclePhysics \ GUI_). 
     26__[CarTelemetry](wiki:CarTelemetry)__ displays the vehicle's internal data. It's used for development and fine-tuning with no typical usage in games.  Easily disabled with __Enabled__ = false.