Sfoglia il codice sorgente

Fixed resource picking in the editor.
Cache DebugRenderer shaders.

Lasse Öörni 12 anni fa
parent
commit
744f51ddf0

+ 5 - 5
Bin/Data/Scripts/Editor/AttributeEditor.as

@@ -964,8 +964,8 @@ void PickResourceDone(StringHash eventType, VariantMap& eventData)
         if (info.type == VAR_RESOURCEREF)
         {
             ResourceRef ref = target.attributes[resourcePickIndex].GetResourceRef();
-            ref.type = resourcePicker.type;
-            ref.id = StringHash(resourceName);
+            ref.type = res.type;
+            ref.id = StringHash(res.name);
             target.attributes[resourcePickIndex] = Variant(ref);
             target.ApplyAttributes();
         }
@@ -974,7 +974,7 @@ void PickResourceDone(StringHash eventType, VariantMap& eventData)
             ResourceRefList refList = target.attributes[resourcePickIndex].GetResourceRefList();
             if (resourcePickSubIndex < refList.length)
             {
-                refList.ids[resourcePickSubIndex] = StringHash(resourceName);
+                refList.ids[resourcePickSubIndex] = StringHash(res.name);
                 target.attributes[resourcePickIndex] = Variant(refList);
                 target.ApplyAttributes();
             }
@@ -983,8 +983,8 @@ void PickResourceDone(StringHash eventType, VariantMap& eventData)
         {
             Array<Variant>@ attrs = target.attributes[resourcePickIndex].GetVariantVector();
             ResourceRef ref = attrs[resourcePickSubIndex].GetResourceRef();
-            ref.type = resourcePicker.type;
-            ref.id = StringHash(resourceName);
+            ref.type = res.type;
+            ref.id = StringHash(res.name);
             attrs[resourcePickSubIndex] = ref;
             target.attributes[resourcePickIndex] = Variant(attrs);
             target.ApplyAttributes();

+ 7 - 1
Engine/Graphics/DebugRenderer.cpp

@@ -314,6 +314,12 @@ void DebugRenderer::Render()
 
     PROFILE(RenderDebugGeometry);
 
+    // Cache shaders
+    if (!vs_)
+        vs_ = renderer->GetVertexShader("Basic_VCol");
+    if (!ps_)
+        ps_ = renderer->GetPixelShader("Basic_VCol");
+    
     unsigned numVertices = (lines_.Size() + noDepthLines_.Size()) * 2;
     // Resize the vertex buffer if too small or much too large
     if (vertexBuffer_->GetVertexCount() < numVertices || vertexBuffer_->GetVertexCount() > numVertices * 2)
@@ -353,7 +359,7 @@ void DebugRenderer::Render()
     graphics->SetDepthWrite(true);
     graphics->SetScissorTest(false);
     graphics->SetStencilTest(false);
-    graphics->SetShaders(renderer->GetVertexShader("Basic_VCol"), renderer->GetPixelShader("Basic_VCol"));
+    graphics->SetShaders(vs_, ps_);
     graphics->SetShaderParameter(VSP_MODEL, Matrix3x4::IDENTITY);
     graphics->SetShaderParameter(VSP_VIEWPROJ, projection_ * view_);
     graphics->SetShaderParameter(PSP_MATDIFFCOLOR, Color(1.0f, 1.0f, 1.0f, 1.0f));

+ 5 - 0
Engine/Graphics/DebugRenderer.h

@@ -36,6 +36,7 @@ class Drawable;
 class Light;
 class Matrix3x4;
 class Renderer;
+class ShaderVariation;
 class Skeleton;
 class Sphere;
 class VertexBuffer;
@@ -115,6 +116,10 @@ private:
     /// Handle end of frame. Clear debug geometry.
     void HandleEndFrame(StringHash eventType, VariantMap& eventData);
     
+    /// Vertex shader.
+    SharedPtr<ShaderVariation> vs_;
+    /// Pixel shader.
+    SharedPtr<ShaderVariation> ps_;
     /// Lines rendered with depth test.
     PODVector<DebugLine> lines_;
     /// Lines rendered without depth test.

+ 1 - 1
Engine/Script/ResourceAPI.cpp

@@ -38,7 +38,7 @@ void RegisterResource(asIScriptEngine* engine)
 
 static Resource* ResourceCacheGetResource(const String& type, const String& name, ResourceCache* ptr)
 {
-    return ptr->GetResource(type, name);
+    return ptr->GetResource(ShortStringHash(type), name);
 }
 
 static File* ResourceCacheGetFile(const String& name, ResourceCache* ptr)