Przeglądaj źródła

Fixed Zone's override-mode and ambient-gradient attribute default value registration. Fixed Editor's hierarchy auto expansion when selecting item via view raycast.

Wei Tjong Yao 12 lat temu
rodzic
commit
a1cd90dff6
2 zmienionych plików z 40 dodań i 58 usunięć
  1. 17 35
      Bin/Data/Scripts/Editor/EditorSceneWindow.as
  2. 23 23
      Engine/Graphics/Zone.cpp

+ 17 - 35
Bin/Data/Scripts/Editor/EditorSceneWindow.as

@@ -462,18 +462,13 @@ void SelectNode(Node@ node, bool multiselect)
         if (!multiselect || !hierarchyList.IsSelected(index))
         {
             // Go in the parent chain up to make sure the chain is expanded
-            for (;;)
+            Node@ current = node;
+            do
             {
-                Node@ parent = node.parent;
-                if (node is editorScene || parent is null)
-                    break;
-                node = parent;
+                hierarchyList.Expand(GetListIndex(current), true);
+                current = current.parent;
             }
-            uint parentIndex = GetListIndex(node);
-            if (parentIndex < numItems)
-                hierarchyList.Expand(parentIndex, true);
-
-            hierarchyList.Expand(index, true);
+            while (current !is null);
         }
 
         // This causes an event to be sent, in response we set the node/component selections, and refresh editors
@@ -488,6 +483,7 @@ void SelectNode(Node@ node, bool multiselect)
 
 void SelectComponent(Component@ component, bool multiselect)
 {
+    Print("Here", true);
     if (component is null && !multiselect)
     {
         hierarchyList.ClearSelection();
@@ -511,24 +507,15 @@ void SelectComponent(Component@ component, bool multiselect)
         if (!multiselect || !hierarchyList.IsSelected(componentIndex))
         {
             // Go in the parent chain up to make sure the chain is expanded
-            for (;;)
-            {
-                Node@ parent = node.parent;
-                if (node is editorScene || parent is null)
-                    break;
-                node = parent;
-            }
-            uint parentNodeIndex = GetListIndex(node);
-            if (parentNodeIndex < numItems)
-                hierarchyList.Expand(parentNodeIndex, true);
-            else if (!multiselect)
+            Node@ current = node;
+            do
             {
-                hierarchyList.ClearSelection();
-                return;
+                hierarchyList.Expand(GetListIndex(current), true);
+                current = current.parent;
             }
-
-            hierarchyList.Expand(nodeIndex, true);
+            while (current !is null);
         }
+        
         // This causes an event to be sent, in response we set the node/component selections, and refresh editors
         if (!multiselect)
             hierarchyList.selection = componentIndex;
@@ -550,18 +537,13 @@ void SelectUIElement(UIElement@ element, bool multiselect)
         if (!multiselect || !hierarchyList.IsSelected(index))
         {
             // Go in the parent chain up to make sure the chain is expanded
-            for (;;)
+            UIElement@ current = element;
+            do
             {
-                UIElement@ parent = element.parent;
-                if (element is editorUIElement || parent is null)
-                    break;
-                element = parent;
+                hierarchyList.Expand(GetListIndex(current), true);
+                current = current.parent;
             }
-            uint parentIndex = GetListIndex(element);
-            if (parentIndex < numItems)
-                hierarchyList.Expand(parentIndex, true);
-
-            hierarchyList.Expand(index, true);
+            while (current !is null);
         }
 
         if (!multiselect)

+ 23 - 23
Engine/Graphics/Zone.cpp

@@ -63,7 +63,7 @@ Zone::~Zone()
 void Zone::RegisterObject(Context* context)
 {
     context->RegisterFactory<Zone>();
-    
+
     ACCESSOR_ATTRIBUTE(Zone, VAR_BOOL, "Is Enabled", IsEnabled, SetEnabled, bool, true, AM_DEFAULT);
     ATTRIBUTE(Zone, VAR_VECTOR3, "Bounding Box Min", boundingBox_.min_, DEFAULT_BOUNDING_BOX_MIN, AM_DEFAULT);
     ATTRIBUTE(Zone, VAR_VECTOR3, "Bounding Box Max", boundingBox_.max_, DEFAULT_BOUNDING_BOX_MAX, AM_DEFAULT);
@@ -71,8 +71,8 @@ void Zone::RegisterObject(Context* context)
     ATTRIBUTE(Zone, VAR_COLOR, "Fog Color", fogColor_, DEFAULT_FOG_COLOR, AM_DEFAULT);
     ATTRIBUTE(Zone, VAR_FLOAT, "Fog Start", fogStart_, DEFAULT_FOG_START, AM_DEFAULT);
     ATTRIBUTE(Zone, VAR_FLOAT, "Fog End", fogEnd_, DEFAULT_FOG_END, AM_DEFAULT);
-    ATTRIBUTE(Zone, VAR_BOOL, "Override Mode", override_, 0, AM_DEFAULT);
-    ATTRIBUTE(Zone, VAR_BOOL, "Ambient Gradient", ambientGradient_, 0, AM_DEFAULT);
+    ATTRIBUTE(Zone, VAR_BOOL, "Override Mode", override_, false, AM_DEFAULT);
+    ATTRIBUTE(Zone, VAR_BOOL, "Ambient Gradient", ambientGradient_, false, AM_DEFAULT);
     ATTRIBUTE(Zone, VAR_INT, "Priority", priority_, 0, AM_DEFAULT);
     ATTRIBUTE(Zone, VAR_INT, "Light Mask", lightMask_, DEFAULT_LIGHTMASK, AM_DEFAULT);
     ATTRIBUTE(Zone, VAR_INT, "Shadow Mask", shadowMask_, DEFAULT_SHADOWMASK, AM_DEFAULT);
@@ -82,7 +82,7 @@ void Zone::RegisterObject(Context* context)
 void Zone::OnSetAttribute(const AttributeInfo& attr, const Variant& src)
 {
     Component::OnSetAttribute(attr, src);
-    
+
     // If bounding box or priority changes, dirty the drawable as applicable
     if ((attr.offset_ >= offsetof(Zone, boundingBox_) && attr.offset_ < (offsetof(Zone, boundingBox_) + sizeof(BoundingBox))) ||
         attr.offset_ == offsetof(Zone, priority_))
@@ -94,7 +94,7 @@ void Zone::OnSetEnabled()
     // When a Zone is disabled, clear the cached zone from all drawables inside bounding box before removing from octree
     if (!IsEnabledEffective())
         OnMarkedDirty(node_);
-    
+
     Drawable::OnSetEnabled();
 }
 
@@ -127,7 +127,7 @@ void Zone::SetFogStart(float start)
 {
     if (start < 0.0f)
         start = 0.0f;
-    
+
     fogStart_ = start;
     MarkNetworkUpdate();
 }
@@ -136,7 +136,7 @@ void Zone::SetFogEnd(float end)
 {
     if (end < 0.0f)
         end = 0.0f;
-    
+
     fogEnd_ = end;
     MarkNetworkUpdate();
 }
@@ -166,7 +166,7 @@ const Matrix3x4& Zone::GetInverseWorldTransform() const
         inverseWorld_ = node_ ? node_->GetWorldTransform().Inverse() : Matrix3x4::IDENTITY;
         inverseWorldDirty_ = false;
     }
-    
+
     return inverseWorld_;
 }
 
@@ -174,10 +174,10 @@ const Color& Zone::GetAmbientStartColor()
 {
     if (!ambientGradient_)
         return ambientColor_;
-    
+
     if (!lastAmbientStartZone_ || !lastAmbientEndZone_)
         UpdateAmbientGradient();
-    
+
     return ambientStartColor_;
 }
 
@@ -185,10 +185,10 @@ const Color& Zone::GetAmbientEndColor()
 {
     if (!ambientGradient_)
         return ambientColor_;
-    
+
     if (!lastAmbientStartZone_ || !lastAmbientEndZone_)
         UpdateAmbientGradient();
-    
+
     return ambientEndColor_;
 }
 
@@ -208,9 +208,9 @@ void Zone::OnMarkedDirty(Node* node)
         scene->DelayedMarkedDirty(this);
         return;
     }
-    
+
     Drawable::OnMarkedDirty(node);
-    
+
     // When marked dirty, clear the cached zone from all drawables inside the zone bounding box,
     // and mark gradient dirty in all neighbor zones
     if (octant_ && lastWorldBoundingBox_.defined_)
@@ -218,7 +218,7 @@ void Zone::OnMarkedDirty(Node* node)
         PODVector<Drawable*> result;
         BoxOctreeQuery query(result, lastWorldBoundingBox_, DRAWABLE_GEOMETRY | DRAWABLE_ZONE);
         octant_->GetRoot()->GetDrawables(query);
-        
+
         for (PODVector<Drawable*>::Iterator i = result.Begin(); i != result.End(); ++i)
         {
             Drawable* drawable = *i;
@@ -233,7 +233,7 @@ void Zone::OnMarkedDirty(Node* node)
             }
         }
     }
-    
+
     lastWorldBoundingBox_ = GetWorldBoundingBox();
     lastAmbientStartZone_.Reset();
     lastAmbientEndZone_.Reset();
@@ -252,20 +252,20 @@ void Zone::UpdateAmbientGradient()
     ambientEndColor_ = ambientColor_;
     lastAmbientStartZone_ = this;
     lastAmbientEndZone_ = this;
-    
+
     if (octant_)
     {
         const Matrix3x4& worldTransform = node_->GetWorldTransform();
         Vector3 center = boundingBox_.Center();
         Vector3 minZPosition = worldTransform * Vector3(center.x_, center.y_, boundingBox_.min_.z_);
         Vector3 maxZPosition = worldTransform * Vector3(center.x_, center.y_, boundingBox_.max_.z_);
-        
+
         PODVector<Zone*> result;
         {
             PointOctreeQuery query(reinterpret_cast<PODVector<Drawable*>&>(result), minZPosition, DRAWABLE_ZONE);
             octant_->GetRoot()->GetDrawables(query);
         }
-        
+
         // Gradient start position: get the highest priority zone that is not this zone
         int bestPriority = M_MIN_INT;
         Zone* bestZone = 0;
@@ -279,13 +279,13 @@ void Zone::UpdateAmbientGradient()
                 bestPriority = priority;
             }
         }
-        
+
         if (bestZone)
         {
             ambientStartColor_ = bestZone->GetAmbientColor();
             lastAmbientStartZone_ = bestZone;
         }
-        
+
         // Do the same for gradient end position
         {
             PointOctreeQuery query(reinterpret_cast<PODVector<Drawable*>&>(result), maxZPosition, DRAWABLE_ZONE);
@@ -293,7 +293,7 @@ void Zone::UpdateAmbientGradient()
         }
         bestPriority = M_MIN_INT;
         bestZone = 0;
-        
+
         for (PODVector<Zone*>::ConstIterator i = result.Begin(); i != result.End(); ++i)
         {
             Zone* zone = *i;
@@ -304,7 +304,7 @@ void Zone::UpdateAmbientGradient()
                 bestPriority = priority;
             }
         }
-        
+
         if (bestZone)
         {
             ambientEndColor_ = bestZone->GetAmbientColor();