Browse Source

Merge remote-tracking branch 'upstream/development' into torquescript-generateCompiler

marauder2k7 1 năm trước cách đây
mục cha
commit
4f3a1f395c

+ 2 - 0
Engine/source/T3D/prefab.cpp

@@ -460,6 +460,8 @@ void Prefab::_onFileChanged( const Torque::Path &path )
 
 Prefab* Prefab::getPrefabByChild( SimObject *child )
 {
+   if (child == NULL) return NULL;
+
    ChildToPrefabMap::Iterator itr = smChildToPrefabMap.find( child->getId() );
    if ( itr == smChildToPrefabMap.end() )
       return NULL;

+ 7 - 0
Engine/source/console/simObject.cpp

@@ -3072,6 +3072,13 @@ DefineEngineMethod( SimObject, setFieldValue, bool, ( const char* fieldName, con
 {
    char fieldNameBuffer[ 1024 ];
    char arrayIndexBuffer[ 64 ];
+
+   if( !fieldName || !fieldName[0] )
+   {
+      AssertFatal(false, "SimObject::setFieldValue - Invalid field name.");
+      Con::errorf( "SimObject::setFieldValue - Invalid field name." );
+      return false;
+   }
    
    // Parse out index if the field is given in the form of 'name[index]'.
    

+ 2 - 2
Engine/source/gui/worldEditor/gizmo.cpp

@@ -961,11 +961,11 @@ void Gizmo::on3DMouseDragged( const Gui3DMouseEvent & event )
          mDeltaTotalPos = projPnt - mMouseDownProjPnt;
          newPosition = mSavedTransform.getPosition() + mDeltaTotalPos;
 
-         mDeltaPos = newPosition - mTransform.getPosition();
-
          if (mProfile->snapToGrid)
             newPosition = _snapPoint(newPosition);
 
+         mDeltaPos = newPosition - mTransform.getPosition();
+
          mTransform.setPosition( newPosition );
 
          mCurrentTransform.setPosition( newPosition );

+ 1 - 0
Engine/source/materials/processedCustomMaterial.cpp

@@ -328,6 +328,7 @@ bool ProcessedCustomMaterial::setupPass( SceneRenderState *state, const SceneDat
 
    shaderConsts->setSafe(rpd->shaderHandles.mAccumTimeSC, MATMGR->getTotalTime());
    shaderConsts->setSafe(rpd->shaderHandles.mDampnessSC, MATMGR->getDampnessClamped());
+   shaderConsts->setSafe(rpd->shaderHandles.mIsCapturingSC, state ? (S32)state->isCapturing() : 0);
    
    return true;
 }

+ 4 - 0
Engine/source/materials/processedShaderMaterial.cpp

@@ -115,6 +115,8 @@ void ShaderConstHandles::init( GFXShader *shader, CustomMaterial* mat /*=NULL*/)
    // MFT_HardwareSkinning
    mNodeTransforms = shader->getShaderConstHandle( "$nodeTransforms" );
 
+   mIsCapturingSC = shader->getShaderConstHandle(ShaderGenVars::isCapturing);
+
    // Clear any existing texture handles.
    dMemset( mTexHandlesSC, 0, sizeof( mTexHandlesSC ) );
    if(mat)
@@ -1093,6 +1095,8 @@ void ProcessedShaderMaterial::_setShaderConstants(SceneRenderState * state, cons
    shaderConsts->setSafe( handles->mAccumTimeSC, MATMGR->getTotalTime() );
 
    shaderConsts->setSafe(handles->mDampnessSC, MATMGR->getDampnessClamped());
+   shaderConsts->setSafe(handles->mIsCapturingSC, (S32)state->isCapturing());
+   
    // If the shader constants have not been lost then
    // they contain the content from a previous render pass.
    //

+ 1 - 0
Engine/source/materials/processedShaderMaterial.h

@@ -104,6 +104,7 @@ public:
 
    GFXShaderConstHandle* mNodeTransforms;
 
+   GFXShaderConstHandle* mIsCapturingSC;
    struct customHandleData
    {
 	   StringTableEntry handleName;

+ 6 - 1
Engine/source/postFx/postEffect.cpp

@@ -498,7 +498,8 @@ PostEffect::PostEffect()
       mMatCameraToWorldSC( NULL),
       mInvCameraTransSC(NULL),
       mMatCameraToScreenSC(NULL),
-      mMatScreenToCameraSC(NULL)
+      mMatScreenToCameraSC(NULL),
+      mIsCapturingSC(NULL)
 {
    dMemset( mTexSRGB, 0, sizeof(bool) * NumTextures);
    dMemset( mActiveTextures, 0, sizeof( GFXTextureObject* ) * NumTextures );
@@ -798,8 +799,12 @@ void PostEffect::_setupConstants( const SceneRenderState *state )
       mInvCameraTransSC = mShader->getShaderConstHandle("$invCameraTrans");
       mMatCameraToScreenSC = mShader->getShaderConstHandle("$cameraToScreen");
       mMatScreenToCameraSC = mShader->getShaderConstHandle("$screenToCamera");
+      mIsCapturingSC = mShader->getShaderConstHandle("$isCapturing");
    }
 
+   if (mIsCapturingSC->isValid())
+      mShaderConsts->set(mIsCapturingSC, (S32)state->isCapturing());
+
    // Set up shader constants for source image size
    if ( mRTSizeSC->isValid() )
    {

+ 2 - 0
Engine/source/postFx/postEffect.h

@@ -164,6 +164,8 @@ protected:
    GFXShaderConstHandle *mMatCameraToScreenSC;
    GFXShaderConstHandle *mMatScreenToCameraSC;
 
+   GFXShaderConstHandle* mIsCapturingSC;
+
    bool mAllowReflectPass;
 
    /// If true update the shader.

+ 2 - 36
Engine/source/renderInstance/renderProbeMgr.cpp

@@ -503,47 +503,13 @@ void RenderProbeMgr::reloadTextures()
 void RenderProbeMgr::preBake()
 {
    RenderProbeMgr::smBakeReflectionProbes = true;
-   GFXShader::addGlobalMacro("CAPTURING", String("1"));
-
-   //Con::setVariable("$Probes::Capturing", "1");
-   mRenderMaximumNumOfLights = AdvancedLightBinManager::smMaximumNumOfLights;
-   mRenderUseLightFade = AdvancedLightBinManager::smUseLightFade;
-
-   AdvancedLightBinManager::smMaximumNumOfLights = -1;
-   AdvancedLightBinManager::smUseLightFade = false;
-
-   //kickstart rendering
-   LightManager* lm = LIGHTMGR;
-   if (lm)
-   {
-      SceneManager* sm = lm->getSceneManager();
-      if (sm && sm->getContainer() == &gClientContainer)
-      {
-         lm->deactivate();
-         lm->activate(sm);
-      }
-   }
+   Con::setBoolVariable("$ReflectionProbes::Capturing", RenderProbeMgr::smBakeReflectionProbes);
 }
 
 void RenderProbeMgr::postBake()
 {
    RenderProbeMgr::smBakeReflectionProbes = false;
-   GFXShader::addGlobalMacro("CAPTURING", String("0"));
-   //Con::setVariable("$Probes::Capturing", "0");
-   AdvancedLightBinManager::smMaximumNumOfLights = mRenderMaximumNumOfLights;
-   AdvancedLightBinManager::smUseLightFade = mRenderUseLightFade;
-
-   //kickstart rendering
-   LightManager* lm = LIGHTMGR;
-   if (lm)
-   {
-      SceneManager* sm = lm->getSceneManager();
-      if (sm && sm->getContainer() == &gClientContainer)
-      {
-         lm->deactivate();
-         lm->activate(sm);
-      }
-   }
+   Con::setBoolVariable("$ReflectionProbes::Capturing", RenderProbeMgr::smBakeReflectionProbes);
 }
 
 void RenderProbeMgr::bakeProbe(ReflectionProbe* probe)

+ 1 - 0
Engine/source/scene/sceneRenderState.h

@@ -223,6 +223,7 @@ class SceneRenderState
       /// Returns true if this is not one of the other rendering passes.
       bool isOtherPass() const { return mScenePassType >= SPT_Other; }
 
+      bool isCapturing() const { return Con::getBoolVariable("$ReflectionProbes::Capturing", false); };
       /// @}
 
       /// @name Render Style

+ 2 - 0
Engine/source/shaderGen/shaderGenVars.cpp

@@ -74,6 +74,8 @@ const String ShaderGenVars::vectorLightDirection("$vectorLightDirection");
 const String ShaderGenVars::vectorLightColor("$vectorLightColor");
 const String ShaderGenVars::vectorLightBrightness("$vectorLightBrightness");
 
+const String ShaderGenVars::isCapturing("$isCapturing");
+
 const String ShaderGenVars::ormConfig("$ORMConfig");
 const String ShaderGenVars::roughness("$roughness");
 const String ShaderGenVars::metalness("$metalness");

+ 2 - 0
Engine/source/shaderGen/shaderGenVars.h

@@ -86,6 +86,8 @@ struct ShaderGenVars
    const static String vectorLightColor;
    const static String vectorLightBrightness;
 
+   const static String isCapturing;
+
    const static String ormConfig;
    const static String roughness;
    const static String metalness;

+ 19 - 27
Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl

@@ -24,6 +24,7 @@
 #include "./brdf.glsl"
 
 uniform float maxProbeDrawDistance;
+uniform int isCapturing;
 
 #ifndef TORQUE_SHADERGEN
 #line 27
@@ -54,10 +55,6 @@ uniform vec4 albedo;
 
 #define MAX_FORWARD_LIGHT 4
 
-#ifndef CAPTURING
-#define CAPTURING 0
-#endif
-
 #ifndef DEBUGVIZ_ATTENUATION
 #define DEBUGVIZ_ATTENUATION 0
 #endif
@@ -237,32 +234,28 @@ vec3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight)
    float D = D_GGX(surfaceToLight.NdotH, surface.linearRoughnessSq);
    vec3 Fr = D * F * Vis;
 
-#if CAPTURING == 1
-   return mix(Fd + Fr, surface.baseColor.rgb, surface.metalness);
-#else
-   return Fd + Fr;
-#endif
-
+   if(isCapturing == 1)
+      return mix(Fd + Fr, surface.baseColor.rgb, surface.metalness);
+   else
+      return Fd + Fr;
 }
 
 vec3 getDirectionalLight(Surface surface, SurfaceToLight surfaceToLight, vec3 lightColor, float lightIntensity, float shadow)
 {
-#if CAPTURING == 1
    float lightfloor = CAPTURE_LIGHT_FLOOR;
-#else
-   float lightfloor = 0.0;
-#endif
+   if(isCapturing != 1)
+      lightfloor = 0.0;
+      
    vec3 factor = lightColor * max(surfaceToLight.NdotL * shadow * lightIntensity, lightfloor);
    return evaluateStandardBRDF(surface,surfaceToLight) * factor;
 }
 
 vec3 getPunctualLight(Surface surface, SurfaceToLight surfaceToLight, vec3 lightColor, float lightIntensity, float radius, float shadow)
 {
-#if CAPTURING == 1
    float lightfloor = CAPTURE_LIGHT_FLOOR;
-#else
-   float lightfloor = 0.0;
-#endif
+   if(isCapturing != 1)
+      lightfloor = 0.0;
+      
    float attenuation = getDistanceAtt(surfaceToLight.Lu, radius);
    vec3 factor = lightColor * max(surfaceToLight.NdotL * shadow * lightIntensity * attenuation, lightfloor);
    return evaluateStandardBRDF(surface,surfaceToLight) * factor;
@@ -270,11 +263,10 @@ vec3 getPunctualLight(Surface surface, SurfaceToLight surfaceToLight, vec3 light
 
 vec3 getSpotlight(Surface surface, SurfaceToLight surfaceToLight, vec3 lightColor, float lightIntensity, float radius, vec3 lightDir, vec2 lightSpotParams, float shadow)
 {
-#if CAPTURING == 1
    float lightfloor = CAPTURE_LIGHT_FLOOR;
-#else
-   float lightfloor = 0.0;
-#endif
+   if(isCapturing != 1)
+      lightfloor = 0.0;
+      
    float attenuation = 1.0f;
    attenuation *= getDistanceAtt(surfaceToLight.Lu, radius);
    attenuation *= getSpotAngleAtt(-surfaceToLight.L, lightDir, lightSpotParams.xy);
@@ -567,11 +559,11 @@ vec4 computeForwardProbes(Surface surface,
    float horizonOcclusion = 1.3;
    float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
    horizon *= horizon;
-#if CAPTURING == 1
-    return vec4(mix((irradiance + specular* horizon),surface.baseColor.rgb,surface.metalness),0);
-#else
-   return vec4((irradiance + specular* horizon) , 0);//alpha writes disabled
-#endif
+   
+   if(isCapturing == 1)
+      return vec4(mix((irradiance + specular* horizon),surface.baseColor.rgb,surface.metalness),0);
+   else
+      return vec4((irradiance + specular* horizon) , 0);//alpha writes disabled
 }
 
 vec4 debugVizForwardProbes(Surface surface,

+ 19 - 27
Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl

@@ -27,6 +27,7 @@
 //globals
 uniform float3 eyePosWorld;
 uniform float maxProbeDrawDistance;
+uniform int isCapturing;
 #ifndef TORQUE_SHADERGEN
 
 // These are the uniforms used by most lighting shaders.
@@ -56,10 +57,6 @@ uniform float4 albedo;
 
 #define MAX_FORWARD_LIGHT 4
 
-#ifndef CAPTURING
-#define CAPTURING 0
-#endif
-
 #ifndef DEBUGVIZ_ATTENUATION
 #define DEBUGVIZ_ATTENUATION 0
 #endif
@@ -238,32 +235,28 @@ float3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight)
    float D = D_GGX(surfaceToLight.NdotH, surface.linearRoughnessSq);
    float3 Fr = D * F * Vis;
 
-#if CAPTURING == 1
-    return lerp(Fd + Fr,surface.baseColor.rgb,surface.metalness);
-#else
-   return Fd + Fr;
-#endif
-
+   if(isCapturing == 1)
+      return lerp(Fd + Fr,surface.baseColor.rgb,surface.metalness);
+   else
+      return Fd + Fr;
 }
 
 float3 getDirectionalLight(Surface surface, SurfaceToLight surfaceToLight, float3 lightColor, float lightIntensity, float shadow)
 {
-#if CAPTURING == 1
    float lightfloor = CAPTURE_LIGHT_FLOOR;
-#else
-   float lightfloor = 0.0;
-#endif
+   if(isCapturing != 1)
+      lightfloor = 0.0;
+        
    float3 factor = lightColor * max(surfaceToLight.NdotL* shadow * lightIntensity, lightfloor) ;
    return evaluateStandardBRDF(surface,surfaceToLight) * factor;
 }
 
 float3 getPunctualLight(Surface surface, SurfaceToLight surfaceToLight, float3 lightColor, float lightIntensity, float radius, float shadow)
 {
-#if CAPTURING == 1
    float lightfloor = CAPTURE_LIGHT_FLOOR;
-#else
-   float lightfloor = 0.0;
-#endif
+   if(isCapturing != 1)
+      lightfloor = 0.0;
+      
    float attenuation = getDistanceAtt(surfaceToLight.Lu, radius);
    float3 factor = lightColor * max(surfaceToLight.NdotL* shadow * lightIntensity * attenuation, lightfloor) ;
    return evaluateStandardBRDF(surface,surfaceToLight) * factor;
@@ -271,11 +264,10 @@ float3 getPunctualLight(Surface surface, SurfaceToLight surfaceToLight, float3 l
 
 float3 getSpotlight(Surface surface, SurfaceToLight surfaceToLight, float3 lightColor, float lightIntensity, float radius, float3 lightDir, float2 lightSpotParams, float shadow)
 {
-#if CAPTURING == 1
    float lightfloor = CAPTURE_LIGHT_FLOOR;
-#else
-   float lightfloor = 0.0;
-#endif
+   if(isCapturing != 1)
+      lightfloor = 0.0;
+      
    float attenuation = 1.0f;
    attenuation *= getDistanceAtt(surfaceToLight.Lu, radius);
    attenuation *= getSpotAngleAtt(-surfaceToLight.L, lightDir, lightSpotParams.xy);
@@ -573,11 +565,11 @@ float4 computeForwardProbes(Surface surface,
    float horizonOcclusion = 1.3;
    float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
    horizon *= horizon;
-#if CAPTURING == 1
-    return float4(lerp((irradiance + specular* horizon),surface.baseColor.rgb,surface.metalness),0);
-#else
-   return float4((irradiance + specular* horizon) , 0);//alpha writes disabled
-#endif
+   
+   if(isCapturing == 1)
+      return float4(lerp((irradiance + specular* horizon),surface.baseColor.rgb,surface.metalness),0);
+   else
+      return float4((irradiance + specular* horizon) , 0);//alpha writes disabled
 }
 
 float4 debugVizForwardProbes(Surface surface,

+ 5 - 5
Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/reflectionProbeArrayP.glsl

@@ -222,9 +222,9 @@ void main()
    float horizonOcclusion = 1.3;
    float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
    horizon *= horizon;
-#if CAPTURING == 1
-   OUT_col = vec4(mix((irradiance + specular* horizon),surface.baseColor.rgb, surface.metalness),0);
-#else
-   OUT_col = vec4((irradiance + specular* horizon)*ambientColor, 0);//alpha writes disabled
-#endif
+   
+   if(isCapturing == 1)
+      OUT_col = vec4(mix((irradiance + specular* horizon),surface.baseColor.rgb, surface.metalness),0);
+   else
+      OUT_col = vec4((irradiance + specular* horizon)*ambientColor, 0);//alpha writes disabled
 }

+ 5 - 5
Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/reflectionProbeArrayP.hlsl

@@ -208,9 +208,9 @@ float4 main(PFXVertToPix IN) : SV_TARGET
    float horizonOcclusion = 1.3;
    float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
    horizon *= horizon;
-#if CAPTURING == 1
-    return float4(lerp((irradiance + specular* horizon), surface.baseColor.rgb,surface.metalness),0);
-#else
-   return float4((irradiance + specular* horizon)*ambientColor, 0);//alpha writes disabled   
-#endif
+   
+   if(isCapturing == 1)
+      return float4(lerp((irradiance + specular* horizon), surface.baseColor.rgb,surface.metalness),0);
+   else
+      return float4((irradiance + specular* horizon)*ambientColor, 0);//alpha writes disabled
 }

+ 3 - 3
Templates/BaseGame/game/data/Prototyping/shapes/Primitives/ArrowPrimitive.asset.taml

@@ -1,5 +1,5 @@
 <ShapeAsset
-    AssetName="Primitive"
-    fileName="@assetFile=Primitive.fbx"
-    constuctorFileName="@assetFile=Primitive.tscript"
+    AssetName="ArrowPrimitive"
+    fileName="@assetFile=ArrowPrimitive.fbx"
+    constuctorFileName="@assetFile=ArrowPrimitive.tscript"
     materialSlot0="@asset=Prototyping:InteractiveRed"/>

+ 4 - 4
Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.tscript

@@ -2535,20 +2535,20 @@ function EWorldEditor::onControlDropped( %this, %payload, %position )
    {
       if(%assetType $= "Datablock")
       {
-         %buildCommand = AssetBrowser @ ".on" @ %assetType @ "EditorDropped(" @ %asset @ ",\"" @ %position @ "\");";
+         %buildCommand = AssetBrowser @ ".on" @ %assetType @ "EditorDropped(" @ %asset @ ",\"" @ %pos @ "\");";
       }
       else if(%assetType $= "Prefab")
       {
-         %buildCommand = AssetBrowser @ ".on" @ %assetType @ "EditorDropped(\"" @ %module @ "/" @ %asset @ "\",\"" @ %position @ "\");";
+         %buildCommand = AssetBrowser @ ".on" @ %assetType @ "EditorDropped(\"" @ %module @ "/" @ %asset @ "\",\"" @ %pos @ "\");";
       }
       else if(%assetType $= "Creator")
       {
-         %buildCommand = AssetBrowser @ ".on" @ %assetType @ "EditorDropped(" @ %module @ ",\"" @ %position @ "\");";
+         %buildCommand = AssetBrowser @ ".on" @ %assetType @ "EditorDropped(" @ %module @ ",\"" @ %pos @ "\");";
       }
       else
       {
          %assetDef = AssetDatabase.acquireAsset(%module @ ":" @ %asset);
-         %buildCommand = AssetBrowser @ ".on" @ %assetType @ "EditorDropped(" @ %assetDef @ ",\"" @ %position @ "\");";
+         %buildCommand = AssetBrowser @ ".on" @ %assetType @ "EditorDropped(" @ %assetDef @ ",\"" @ %pos @ "\");";
       }
       eval(%buildCommand);