Pārlūkot izejas kodu

arrayed BS, blend & discard icons by distance

MonkeyFirst 10 gadi atpakaļ
vecāks
revīzija
cb6039a2b9
1 mainītis faili ar 221 papildinājumiem un 421 dzēšanām
  1. 221 421
      bin/Data/Scripts/Editor/EditorViewDebugIcons.as

+ 221 - 421
bin/Data/Scripts/Editor/EditorViewDebugIcons.as

@@ -1,482 +1,282 @@
 // Editor debug icons
+// to add new std debug icons just add IconType, IconsTypesMaterials and ComponentTypes items
 
-BillboardSet@ debugIconsSetDirectionalLights;
-BillboardSet@ debugIconsSetSpotLights;
-BillboardSet@ debugIconsSetPointLights;
-BillboardSet@ debugIconsSetCameras;
-BillboardSet@ debugIconsSetSoundSources;
-BillboardSet@ debugIconsSetSoundSources3D;
-BillboardSet@ debugIconsSetSoundListeners;
-BillboardSet@ debugIconsSetZones;
-BillboardSet@ debugIconsSetSplinesPoints;
-BillboardSet@ debugIconsSetTriggers;
-BillboardSet@ debugIconsSetCustomGeometry;
-BillboardSet@ debugIconsSetParticleEmitters;
+enum IconsTypes 
+{
+    ICON_POINT_LIGHT = 0,
+    ICON_SPOT_LIGHT,
+    ICON_DIRECTIONAL_LIGHT,
+    ICON_CAMERA,
+    ICON_SOUND_SOURCE,
+    ICON_SOUND_SOURCE_3D,
+    ICON_SOUND_LISTENERS,
+    ICON_ZONE,
+    ICON_SPLINE_PATH,
+    ICON_TRIGGER,
+    ICON_CUSTOM_GEOMETRY,
+    ICON_PARTICLE_EMITTER,
+    ICON_COUNT
+}
 
+enum IconsColorType 
+{
+    ICON_COLOR_DEFAULT = 0,
+    ICON_COLOR_SPLINE_PATH_BEGIN,
+    ICON_COLOR_SPLINE_PATH_END
+}
 
+Array<Color> debugIconsColors = { Color(1,1,1) , Color(1,1,0), Color(0,1,0) };
 
+Array<String> IconsTypesMaterials = {"DebugIconPointLight.xml", 
+                                     "DebugIconSpotLight.xml",
+                                     "DebugIconLight.xml",
+                                     "DebugIconCamera.xml",
+                                     "DebugIconSoundSource.xml",
+                                     "DebugIconSoundSource.xml",
+                                     "DebugIconSoundListener.xml",
+                                     "DebugIconZone.xml",
+                                     "DebugIconSplinePathPoint.xml",
+                                     "DebugIconCollisionTrigger.xml",
+                                     "DebugIconCustomGeometry.xml",
+                                     "DebugIconParticleEmitter.xml"};
+                                     
+                                     
+Array<String> ComponentTypes = {"Light", 
+                                "Light",
+                                "Light",
+                                "Camera",
+                                "SoundSource",
+                                "SoundSource3D",
+                                "SoundListener",
+                                "Zone",
+                                "SplinePath",
+                                "RigidBody",
+                                "CustomGeometry",
+                                "ParticleEmitter"}; 
+                                     
+Array<BillboardSet@> debugIconsSet(ICON_COUNT);
 
 Node@ debugIconsNode = null;
-int stepDebugIconsUpdate = 60; //ms
+int stepDebugIconsUpdate = 100; //ms
 int timeToNextDebugIconsUpdate = 0;
-int stepDebugIconsUpdateSplinePath = 500; //ms
+int stepDebugIconsUpdateSplinePath = 1000; //ms
 int timeToNextDebugIconsUpdateSplinePath = 0;
 const int splinePathResolution = 16;
+const float splineStep = 1.0f / splinePathResolution;
 bool debugIconsShow = true;
 bool supressDebugIconsShow = false;
 Vector2 debugIconsSize = Vector2(0.025, 0.025);
 Vector2 debugIconsSizeSmall = debugIconsSize / 1.5;
 Vector2 debugIconsSizeBig = debugIconsSize * 1.5;
-
+Vector2 debugIconsMaxSize = debugIconsSize * 50;
+VariantMap debugIconsPlacement;
+const int debugIconsPlacementIndent = 1.0;  
 
 Vector2 Max(Vector2 a, Vector2 b) 
 {
     return (a.length > b.length ? a : b); 
 }
 
-void CreateDebugIcons() 
+Vector2 Clamp(Vector2 a, Vector2 b) 
 {
-    if (editorScene is null) return;
-    
-    debugIconsSetDirectionalLights = debugIconsNode.CreateComponent("BillboardSet");
-    debugIconsSetDirectionalLights.material = cache.GetResource("Material", "Materials/Editor/DebugIconLight.xml");
-    debugIconsSetDirectionalLights.material.renderOrder = 255;
-    debugIconsSetDirectionalLights.sorted = true;
-    debugIconsSetDirectionalLights.temporary = true;
-    debugIconsSetDirectionalLights.viewMask = 0x80000000;
-    
-    debugIconsSetSpotLights = debugIconsNode.CreateComponent("BillboardSet");
-    debugIconsSetSpotLights.material = cache.GetResource("Material", "Materials/Editor/DebugIconSpotLight.xml");
-    debugIconsSetSpotLights.material.renderOrder = 255;
-    debugIconsSetSpotLights.sorted = true;
-    debugIconsSetSpotLights.temporary = true;
-    debugIconsSetSpotLights.viewMask = 0x80000000;
-    
-    debugIconsSetPointLights = debugIconsNode.CreateComponent("BillboardSet");
-    debugIconsSetPointLights.material = cache.GetResource("Material", "Materials/Editor/DebugIconPointLight.xml");
-    debugIconsSetPointLights.material.renderOrder = 255;
-    debugIconsSetPointLights.sorted = true;
-    debugIconsSetPointLights.temporary = true;
-    debugIconsSetPointLights.viewMask = 0x80000000;
-        
-    debugIconsSetCameras = debugIconsNode.CreateComponent("BillboardSet");
-    debugIconsSetCameras.material = cache.GetResource("Material", "Materials/Editor/DebugIconCamera.xml");
-    debugIconsSetCameras.material.renderOrder = 255;
-    debugIconsSetCameras.sorted = true;
-    debugIconsSetCameras.temporary = true;
-    debugIconsSetCameras.viewMask = 0x80000000;
-    
-    debugIconsSetSoundSources = debugIconsNode.CreateComponent("BillboardSet");
-    debugIconsSetSoundSources.material = cache.GetResource("Material", "Materials/Editor/DebugIconSoundSource.xml");
-    debugIconsSetSoundSources.material.renderOrder = 255;
-    debugIconsSetSoundSources.sorted = true;
-    debugIconsSetSoundSources.temporary = true;
-    debugIconsSetSoundSources.viewMask = 0x80000000;
-
-    debugIconsSetSoundSources3D = debugIconsNode.CreateComponent("BillboardSet");
-    debugIconsSetSoundSources3D.material = cache.GetResource("Material", "Materials/Editor/DebugIconSoundSource.xml");
-    debugIconsSetSoundSources3D.material.renderOrder = 255;
-    debugIconsSetSoundSources3D.sorted = true;
-    debugIconsSetSoundSources3D.temporary = true;
-    debugIconsSetSoundSources3D.viewMask = 0x80000000;
-    
-    debugIconsSetSoundListeners = debugIconsNode.CreateComponent("BillboardSet");
-    debugIconsSetSoundListeners.material = cache.GetResource("Material", "Materials/Editor/DebugIconSoundListener.xml");
-    debugIconsSetSoundListeners.material.renderOrder = 255;
-    debugIconsSetSoundListeners.sorted = true;
-    debugIconsSetSoundListeners.temporary = true;
-    debugIconsSetSoundListeners.viewMask = 0x80000000;
-    
-    debugIconsSetZones = debugIconsNode.CreateComponent("BillboardSet");
-    debugIconsSetZones.material = cache.GetResource("Material", "Materials/Editor/DebugIconZone.xml");
-    debugIconsSetZones.material.renderOrder = 255;
-    debugIconsSetZones.sorted = true;
-    debugIconsSetZones.temporary = true;
-    debugIconsSetZones.viewMask = 0x80000000;
-    
-    debugIconsSetSplinesPoints = debugIconsNode.CreateComponent("BillboardSet");
-    debugIconsSetSplinesPoints.material = cache.GetResource("Material", "Materials/Editor/DebugIconSplinePathPoint.xml");
-    debugIconsSetSplinesPoints.material.renderOrder = 255;
-    debugIconsSetSplinesPoints.sorted = true;
-    debugIconsSetSplinesPoints.temporary = true;
-    debugIconsSetSplinesPoints.viewMask = 0x80000000;
-    
-    debugIconsSetTriggers = debugIconsNode.CreateComponent("BillboardSet");
-    debugIconsSetTriggers.material = cache.GetResource("Material", "Materials/Editor/DebugIconCollisionTrigger.xml");
-    debugIconsSetTriggers.material.renderOrder = 255;
-    debugIconsSetTriggers.sorted = true;
-    debugIconsSetTriggers.temporary = true;
-    debugIconsSetTriggers.viewMask = 0x80000000;
-    
-    debugIconsSetCustomGeometry = debugIconsNode.CreateComponent("BillboardSet");
-    debugIconsSetCustomGeometry.material = cache.GetResource("Material", "Materials/Editor/DebugIconCustomGeometry.xml");
-    debugIconsSetCustomGeometry.material.renderOrder = 255;
-    debugIconsSetCustomGeometry.sorted = true;
-    debugIconsSetCustomGeometry.temporary = true;
-    debugIconsSetCustomGeometry.viewMask = 0x80000000;
-    
-    debugIconsSetParticleEmitters = debugIconsNode.CreateComponent("BillboardSet");
-    debugIconsSetParticleEmitters.material = cache.GetResource("Material", "Materials/Editor/DebugIconParticleEmitter.xml");
-    debugIconsSetParticleEmitters.material.renderOrder = 255;
-    debugIconsSetParticleEmitters.sorted = true;
-    debugIconsSetParticleEmitters.temporary = true;
-    debugIconsSetParticleEmitters.viewMask = 0x80000000; 
-
+    return Vector2((a.x > b.x ? b.x : a.x),(a.y > b.y ? b.y : a.y));
+}
 
+Vector2 ClampToIconMaxSize(Vector2 a) 
+{
+    return Clamp(a, debugIconsMaxSize);
 }
 
-void UpdateViewDebugIcons() 
+void CreateDebugIcons(Node@ tempNode) 
 {
     if (editorScene is null) return;
-    
-    if (timeToNextDebugIconsUpdate > time.systemTime) return; 
+    debugIconsSet.Resize(ICON_COUNT);
+    for (int i=0;i<ICON_COUNT;i++) 
+    {
+        debugIconsSet[i] = tempNode.CreateComponent("BillboardSet");
+        debugIconsSet[i].material = cache.GetResource("Material", "Materials/Editor/" + IconsTypesMaterials[i]);
+        debugIconsSet[i].sorted = true;
+        debugIconsSet[i].temporary = true;
+        debugIconsSet[i].viewMask = 0x80000000;
+    }
+}
+
+void UpdateViewDebugIcons() 
+{    
+    if (editorScene is null || timeToNextDebugIconsUpdate > time.systemTime) return;
     
     debugIconsNode = editorScene.GetChild("DebugIconsContainer", true);
     
-    
     if (debugIconsNode is null) 
     {
         debugIconsNode = editorScene.CreateChild("DebugIconsContainer", LOCAL);
         debugIconsNode.temporary = true;
-    } 
-    
-    
-    // Checkout if debugIconsNode do not have any BBS component, add they at once
-    BillboardSet@ bbs = debugIconsNode.GetComponent("BillboardSet");
-    
-    if (bbs is null) 
-    {
-        CreateDebugIcons();
-    }
-        
-    if (debugIconsSetPointLights !is null) 
-    {
-        debugIconsSetDirectionalLights.enabled = debugIconsShow;
-        debugIconsSetSpotLights.enabled = debugIconsShow;
-        debugIconsSetPointLights.enabled = debugIconsShow;
-        debugIconsSetCameras.enabled = debugIconsShow;
-        debugIconsSetSoundSources.enabled = debugIconsShow;
-        debugIconsSetSoundSources3D.enabled = debugIconsShow;
-        debugIconsSetSoundListeners.enabled = debugIconsShow;
-        debugIconsSetZones.enabled = debugIconsShow;
-        debugIconsSetSplinesPoints.enabled = debugIconsShow;
-        debugIconsSetTriggers.enabled = debugIconsShow;
-        debugIconsSetCustomGeometry.enabled = debugIconsShow;
-        debugIconsSetParticleEmitters.enabled = debugIconsShow;
-           
-    }
-    
-    if (debugIconsShow == false) return; 
-    
-    Vector3 camPos = activeViewport.cameraNode.worldPosition;
-        
-    if (debugIconsSetPointLights !is null) 
-    {
-        Array<Node@> nodes = editorScene.GetChildrenWithComponent("Light", true);
-        
-        if (nodes.length > 0) 
-        {
-            debugIconsSetDirectionalLights.numBillboards = 0;
-            debugIconsSetSpotLights.numBillboards = 0;
-            debugIconsSetPointLights.numBillboards = 0;
-            
-            debugIconsSetPointLights.Commit();
-            debugIconsSetSpotLights.Commit();
-            debugIconsSetDirectionalLights.Commit();
-            
-            debugIconsSetDirectionalLights.numBillboards = nodes.length;
-            debugIconsSetSpotLights.numBillboards = nodes.length;
-            debugIconsSetPointLights.numBillboards = nodes.length;
-            
-            for (int i=0;i<nodes.length; i++) 
-            {
-                Light@ light = nodes[i].GetComponent("Light");
-                
-                if (light.lightType == LIGHT_POINT) 
-                {
-                    Billboard@ bb = debugIconsSetPointLights.billboards[i];
-                    bb.position = nodes[i].worldPosition;
-                    bb.color = light.effectiveColor;
-                    float distance = (camPos - nodes[i].worldPosition).length;
-                    bb.size = Max(debugIconsSize * distance, debugIconsSize);  
-                    bb.enabled = true;
-                }
-                else if (light.lightType == LIGHT_DIRECTIONAL) 
-                {
-                    Billboard@ bb = debugIconsSetDirectionalLights.billboards[i];
-                    bb.position = nodes[i].worldPosition;
-                    bb.color = light.effectiveColor;
-                    float distance = (camPos - nodes[i].worldPosition).length;
-                    bb.size = Max(debugIconsSize * distance, debugIconsSize);
-                    bb.enabled = true;
-                }
-                else if (light.lightType == LIGHT_SPOT) 
-                {
-                    Billboard@ bb = debugIconsSetSpotLights.billboards[i];
-                    bb.position = nodes[i].worldPosition;
-                    bb.color = light.effectiveColor;
-                    float distance = (camPos - nodes[i].worldPosition).length;
-                    bb.size = Max(debugIconsSize * distance, debugIconsSize);
-                    bb.enabled = true;
-                }
-            }
-            
-            debugIconsSetPointLights.Commit();
-            debugIconsSetSpotLights.Commit();
-            debugIconsSetDirectionalLights.Commit();
-            
-        }
     }
+    // Checkout if debugIconsNode do not have any BBS component, add all at once
+    BillboardSet@ isBSExist = debugIconsNode.GetComponent("BillboardSet");
+    if (isBSExist is null) CreateDebugIcons(debugIconsNode);
     
-    
-    if (debugIconsSetCameras !is null) 
+    if (debugIconsSet[ICON_POINT_LIGHT] !is null) 
     {
-        Array<Node@> nodes = editorScene.GetChildrenWithComponent("Camera", true);
-
-        if (nodes.length > 0) 
-        {
-            debugIconsSetCameras.numBillboards = nodes.length;
-            for (int i=0;i<nodes.length; i++) 
-            {
-                Camera@ camera = nodes[i].GetComponent("Camera");
-                Billboard@ bb = debugIconsSetCameras.billboards[i];
-                bb.position = nodes[i].worldPosition;
-                
-                // if mainCamera enough closer to selected camera then make bb size relative to distance
-                float distance = (camPos - nodes[i].worldPosition).length;
-                bb.size = Max(debugIconsSize * distance, debugIconsSize);  
-                bb.enabled = true;
-            }
-            
-            debugIconsSetCameras.Commit();
-        }
+        for(int i=0; i < ICON_COUNT; i++)
+            debugIconsSet[i].enabled = debugIconsShow;
     }
     
-    if (debugIconsSetSoundSources !is null) 
-    {   
-        Array<Node@> nodes = editorScene.GetChildrenWithComponent("SoundSource", true);
-
-        if (nodes.length > 0) 
-        {
-            debugIconsSetSoundSources.numBillboards = nodes.length;
-            for (int i=0;i<nodes.length; i++) 
-            {
-                Component@ component = nodes[i].GetComponent("SoundSource");
-                Billboard@ bb = debugIconsSetSoundSources.billboards[i];
-                bb.position = nodes[i].worldPosition;
-                float distance = (camPos - nodes[i].worldPosition).length;
-                bb.size = Max(debugIconsSize * distance, debugIconsSize);
-                bb.enabled = component.enabled;
-            }
-            
-            debugIconsSetSoundSources.Commit();
-        }        
-    }
+    if (debugIconsShow == false) return;
     
-    if (debugIconsSetSoundSources3D !is null) 
-    {   
-        Array<Node@> nodes = editorScene.GetChildrenWithComponent("SoundSource3D", true);
-
-        if (nodes.length > 0) 
-        {
-            debugIconsSetSoundSources3D.numBillboards = nodes.length;
-            for (int i=0;i<nodes.length; i++) 
-            {
-                Component@ component = nodes[i].GetComponent("SoundSource3D");
-                Billboard@ bb = debugIconsSetSoundSources3D.billboards[i];
-                bb.position = nodes[i].worldPosition;
-                float distance = (camPos - nodes[i].worldPosition).length;
-                bb.size = Max(debugIconsSize * distance, debugIconsSize);
-                bb.enabled = component.enabled;
-            }
-            
-            debugIconsSetSoundSources3D.Commit();
-        }        
-    }
-    
-    if (debugIconsSetSoundListeners !is null) 
+    Vector3 camPos = activeViewport.cameraNode.worldPosition;
+    debugIconsPlacement.Clear();
+     
+    for(int iconType=0; iconType<ICON_COUNT; iconType++)
     {
-        Array<Node@> nodes = editorScene.GetChildrenWithComponent("SoundListener" , true);
-
-        if (nodes.length > 0) 
+        if(debugIconsSet[iconType] !is null) 
         {
-            debugIconsSetSoundListeners.numBillboards = nodes.length;
-            for (int i=0;i<nodes.length; i++) 
-            {
-                Component@ component = nodes[i].GetComponent("SoundListener");
-                Billboard@ bb = debugIconsSetSoundListeners.billboards[i];
-                bb.position = nodes[i].worldPosition;
-                float distance = (camPos - nodes[i].worldPosition).length;
-                bb.size = Max(debugIconsSize * distance, debugIconsSize);
-                bb.enabled = component.enabled;
-            }
+            // SplinePath update resolution
+            if(iconType == ICON_SPLINE_PATH && timeToNextDebugIconsUpdateSplinePath > time.systemTime) continue;
             
-            debugIconsSetSoundListeners.Commit();
-        }        
-    }
-    
-    if (debugIconsSetZones !is null) 
-    {
-        // Collect all scene's Zones and add it
-        Array<Node@> nodes = editorScene.GetChildrenWithComponent("Zone", true);
-        
-        Zone@ zone = editorScene.GetComponent("Zone");
-        if (zone !is null) 
-        {
-            debugIconsSetZones.numBillboards = 1;
-            Billboard@ bb = debugIconsSetZones.billboards[0];
-            bb.position = Vector3(0,0,0);
-            float distance = (camPos - bb.position).length;
-            bb.size = Max(debugIconsSize * distance, debugIconsSize);
-            //bb.color = zone.ambientColor;
-            bb.enabled = zone.enabled; 
-        }
-        
-        if (nodes.length > 0) 
-        {
-            debugIconsSetZones.numBillboards = 1 + nodes.length;
-            for (int i=0;i<nodes.length; i++) 
+            Array<Node@> nodes = editorScene.GetChildrenWithComponent(ComponentTypes[iconType], true);
+            if(nodes.length > 0) 
             {
-                Zone@ zone = nodes[i].GetComponent("Zone");
-                Billboard@ bb = debugIconsSetZones.billboards[i+1];
-                bb.position = nodes[i].worldPosition;
-                float distance = (camPos - nodes[i].worldPosition).length;
-                bb.size = Max(debugIconsSize * distance, debugIconsSize);
-                //bb.color = zone.ambientColor;
-                bb.enabled = zone.enabled;
-            }
+                // Clear old data
+                if(iconType == ICON_SPLINE_PATH)
+                    ClearCommit(ICON_SPLINE_PATH, ICON_SPLINE_PATH+1, nodes.length * splinePathResolution);
+                else if(iconType==ICON_POINT_LIGHT || iconType==ICON_SPOT_LIGHT || iconType==ICON_DIRECTIONAL_LIGHT)
+                    ClearCommit(ICON_POINT_LIGHT, ICON_DIRECTIONAL_LIGHT+1, nodes.length);
+                else if(iconType==ICON_SOUND_SOURCE || iconType==ICON_SOUND_SOURCE_3D)
+                    ClearCommit(ICON_SOUND_SOURCE, ICON_SOUND_SOURCE_3D+1, nodes.length);
+                else
+                    ClearCommit(iconType, iconType+1, nodes.length);
             
-            debugIconsSetZones.Commit();
-        }
-    }
-    
-    if (timeToNextDebugIconsUpdateSplinePath < time.systemTime) 
-    {
-        if (debugIconsSetSplinesPoints !is null) 
-        {
-            // Collect all scene's SplinePath and add it
-            Array<Node@> nodes = editorScene.GetChildrenWithComponent("SplinePath", true);
-            
-            if (nodes.length > 0) 
-            {
-                debugIconsSetSplinesPoints.numBillboards = nodes.length * splinePathResolution;
-                
-                float splineStep = 1.0f / splinePathResolution;
-                                        
-                for(int i=0; i < nodes.length; i++) 
-                {
+                // Fill with new data
+                for(int i=0;i<nodes.length; i++) 
+                {                    
+                    Component@ component = nodes[i].GetComponent(ComponentTypes[iconType]);
+                    if (component is null) continue;
                     
-                    SplinePath@ sp = nodes[i].GetComponent("SplinePath");
-                    if(sp !is null) 
+                    Billboard@ bb = null;
+                    Color finalIconColor = debugIconsColors[ICON_COLOR_DEFAULT];
+                    float distance = (camPos - nodes[i].worldPosition).length;
+                    int iconsOffset = debugIconsPlacement[StringHash(nodes[i].id)].GetInt();
+                    float iconsYPos = 0;
+                     
+                    if(iconType==ICON_SPLINE_PATH) 
+                    {    
+                        SplinePath@ sp = cast<SplinePath>(component);
+                        if(sp !is null)
+                        {    
+                            for(int step=0; step < splinePathResolution; step++) 
+                            {
+                                int index = (i * splinePathResolution) + step;
+                                Vector3 splinePoint = sp.GetPoint(splineStep * step);
+                                Billboard@ bb = debugIconsSet[ICON_SPLINE_PATH].billboards[index];
+                                float stepDistance = (camPos - splinePoint).length;
+                                
+                                if(step == 0) // SplinePath start
+                                {
+                                    bb.color = debugIconsColors[ICON_COLOR_SPLINE_PATH_BEGIN];
+                                    bb.size = ClampToIconMaxSize(Max(debugIconsSize * stepDistance, debugIconsSize));
+                                    
+                                    
+                                    bb.position = splinePoint;
+                                }
+                                else if((step+1) >= (splinePathResolution - splineStep)) // SplinePath end
+                                {
+                                    bb.color = debugIconsColors[ICON_COLOR_SPLINE_PATH_END];
+                                    bb.size = ClampToIconMaxSize(Max(debugIconsSize * stepDistance, debugIconsSize));
+                                    
+                                    
+                                    bb.position = splinePoint;
+                                }
+                                else // SplinePath middle points
+                                {
+                                    bb.color = finalIconColor;
+                                    bb.size = ClampToIconMaxSize(Max(debugIconsSizeSmall * stepDistance, debugIconsSizeSmall));
+                                    bb.position = splinePoint;
+                                }
+                                bb.enabled = sp.enabled;
+                                // Blend Icon relatively by distance to it
+                                bb.color = Color(bb.color.r, bb.color.g, bb.color.b, 1.2f - 1.0f / (debugIconsMaxSize.x / bb.size.x));
+                                if (bb.color.a < 0.25f) bb.enabled = false;   
+                            }
+                            //IncrementIconPlacement(sp.enabled, nodes[i], bb.size.y);
+                        }
+                    }
+                    else
                     {
-                        Vector3 splinePoint;
-                        // Create path
-                        for(int step=0; step < splinePathResolution; step++) 
+                        bb = debugIconsSet[iconType].billboards[i];
+                        bb.size = ClampToIconMaxSize(Max(debugIconsSize * distance, debugIconsSize));
+                        
+                        if(iconType==ICON_PARTICLE_EMITTER)
                         {
-                            splinePoint = sp.GetPoint(splineStep * step);
-                            
-                            float distance = (camPos - splinePoint).length;
-                            int index = (i * splinePathResolution) + step;    
-                            Billboard@ bb = debugIconsSetSplinesPoints.billboards[index];
-                            bb.position = splinePoint;
-                            
-                            if (step == 0) 
+                            bb.size = ClampToIconMaxSize(Max(debugIconsSizeBig * distance, debugIconsSizeBig));
+                        }
+                        else if (iconType==ICON_TRIGGER)
+                        {
+                            RigidBody@ rigidbody = cast<RigidBody>(component);
+                            if (rigidbody !is null)
                             {
-                                bb.color = Color(1,1,0);
-                                bb.size = Max(debugIconsSize * distance, debugIconsSize);
+                                if (rigidbody.trigger == false) continue;
                             }
-                            else if ((step+1) >= (splinePathResolution - splineStep))
+                        }
+                        else if (iconType==ICON_POINT_LIGHT || iconType==ICON_SPOT_LIGHT || iconType==ICON_DIRECTIONAL_LIGHT)
+                        {
+                            Light@ light = cast<Light>(component);
+                            if(light !is null)
                             {
-                                bb.color = Color(0,1,0);
-                                bb.size = Max(debugIconsSize * distance, debugIconsSize);
+                                if(light.lightType == LIGHT_POINT) 
+                                    bb = debugIconsSet[ICON_POINT_LIGHT].billboards[i];
+                                else if(light.lightType == LIGHT_DIRECTIONAL) 
+                                    bb = debugIconsSet[ICON_DIRECTIONAL_LIGHT].billboards[i];
+                                else if(light.lightType == LIGHT_SPOT)
+                                    bb = debugIconsSet[ICON_SPOT_LIGHT].billboards[i];
+                                
+                                bb.size = ClampToIconMaxSize(Max(debugIconsSize * distance, debugIconsSize));
+                                finalIconColor = light.effectiveColor; 
                             }
-                            else
-                            {
-                                bb.color = Color(1,1,1);
-                                bb.size = Max(debugIconsSizeSmall * distance, debugIconsSizeSmall);
-                            }    
-                            bb.enabled = sp.enabled;
                         }
-                    }                                       
-                }
-                
-                debugIconsSetSplinesPoints.Commit();   
-            }
-        }
-        
-        if (debugIconsSetTriggers !is null) 
-        {
-            // Collect all scene's RigidBody and add it
-            Array<Node@> nodes = editorScene.GetChildrenWithComponent("RigidBody", true);
-            
-            if (nodes.length > 0) 
-            {
-                debugIconsSetTriggers.numBillboards = nodes.length;
-                for (int i=0;i<nodes.length; i++) 
-                {
-                    RigidBody@ rigidbody = nodes[i].GetComponent("RigidBody");
-                    if (rigidbody.trigger) 
-                    {
-                        Billboard@ bb = debugIconsSetTriggers.billboards[i];
+                        
                         bb.position = nodes[i].worldPosition;
-                        float distance = (camPos - nodes[i].worldPosition).length;
-                        bb.size = Max(debugIconsSize * distance, debugIconsSize);
-                        bb.enabled = rigidbody.enabled;
-                    }
+                           
+                        // Blend Icon relatively by distance to it
+                        bb.color = Color(finalIconColor.r, finalIconColor.g, finalIconColor.b, 1.2f - 1.0f / (debugIconsMaxSize.x / bb.size.x));
+                        bb.enabled = component.enabled;
+                        // Discard billboard if it almost transparent
+                        if (bb.color.a < 0.25f) bb.enabled = false;
+                        IncrementIconPlacement(bb.enabled, nodes[i], 1 );   
+                    }   
                 }
-                
-                debugIconsSetTriggers.Commit();   
+                Commit(iconType, iconType+1);
+                // SplinePath update resolution
+                if(iconType == ICON_SPLINE_PATH) timeToNextDebugIconsUpdateSplinePath = time.systemTime + stepDebugIconsUpdateSplinePath;
             }
         }
-        
-        if (debugIconsSetCustomGeometry !is null) 
-        {
-            // Collect all scene's CustomGeometry and add it
-            Array<Node@> nodes = editorScene.GetChildrenWithComponent("CustomGeometry", true);
-            
-            if (nodes.length > 0) 
-            {
-                debugIconsSetCustomGeometry.numBillboards = nodes.length;
-                for (int i=0;i<nodes.length; i++) 
-                {
-                    CustomGeometry@ customGeometry = nodes[i].GetComponent("CustomGeometry");
+    }   
+    timeToNextDebugIconsUpdate = time.systemTime + stepDebugIconsUpdate;
+}
 
-                    Billboard@ bb = debugIconsSetCustomGeometry.billboards[i];
-                    bb.position = nodes[i].worldPosition;
-                    float distance = (camPos - nodes[i].worldPosition).length;
-                    bb.size = Max(debugIconsSize * distance, debugIconsSize);
-                    bb.enabled = customGeometry.enabled;
-                }
-                
-                debugIconsSetCustomGeometry.Commit();   
-            }
-        }
-        
-        if (debugIconsSetParticleEmitters !is null) 
-        {
-            // Collect all scene's ParticleEmitter and add it
-            Array<Node@> nodes = editorScene.GetChildrenWithComponent("ParticleEmitter", true);
-            
-            if (nodes.length > 0) 
-            {
-                debugIconsSetParticleEmitters.numBillboards = nodes.length;
-                for (int i=0;i<nodes.length; i++) 
-                {
-                    ParticleEmitter@ particleEmitter = nodes[i].GetComponent("ParticleEmitter");
+void ClearCommit(int begin, int end, int newlength) 
+{
+    for(int i=begin;i<end;i++)
+    {
+        debugIconsSet[i].numBillboards = 0;
+        debugIconsSet[i].Commit();
+        debugIconsSet[i].numBillboards = newlength;
+    }
+}
 
-                    Billboard@ bb = debugIconsSetParticleEmitters.billboards[i];
-                    bb.position = nodes[i].worldPosition;
-                    float distance = (camPos - nodes[i].worldPosition).length;
-                    bb.size = Max(debugIconsSizeBig * distance, debugIconsSizeBig);
-                    bb.enabled = particleEmitter.enabled;
-                }
-                
-                debugIconsSetParticleEmitters.Commit();   
-            }
-        }
-        
-        timeToNextDebugIconsUpdateSplinePath = time.systemTime + stepDebugIconsUpdateSplinePath;
+void Commit(int begin, int end) 
+{
+    for(int i=begin;i<end;i++)
+    {
+        debugIconsSet[i].Commit();
+    }
+}
+
+void IncrementIconPlacement(bool componentEnabled, Node@ node, int offset)
+{
+    if(componentEnabled == true)
+    {
+        int oldPlacement = debugIconsPlacement[StringHash(node.id)].GetInt();
+        debugIconsPlacement[StringHash(node.id)] = Variant(oldPlacement + offset);
     }
-    
-    timeToNextDebugIconsUpdate = time.systemTime + stepDebugIconsUpdate;
 }