Various fixes

Separated baked cubemap load/processing logic into a separate function for clarity
various corrections for when fields change so it properly notifies down to the client
Fixed enable flag logic to actually work
Fixed skylight enable flag so it properly disables if flipped off
This commit is contained in:
Areloch 2019-06-05 00:07:46 -05:00
parent a552471e4e
commit 27b304eec3
8 changed files with 208 additions and 181 deletions

View file

@ -152,8 +152,13 @@ void BoxEnvironmentProbe::unpackUpdate(NetConnection *conn, BitStream *stream)
void BoxEnvironmentProbe::updateProbeParams()
{
if (!mProbeInfo)
return;
mProbeShapeType = ProbeRenderInst::Box;
mProbeInfo->mAtten = mAtten;
Parent::updateProbeParams();
}
void BoxEnvironmentProbe::setPreviewMatParameters(SceneRenderState* renderState, BaseMatInstance* mat)

View file

@ -143,10 +143,7 @@ ReflectionProbe::~ReflectionProbe()
if (mEditorShapeInst)
SAFE_DELETE(mEditorShapeInst);
if (mProbeInfo)
SAFE_DELETE(mProbeInfo);
if (mReflectionModeType != StaticCubemap && mStaticCubemap)
if (mReflectionModeType == StaticCubemap && mStaticCubemap)
mStaticCubemap->deleteObject();
}
@ -209,7 +206,7 @@ bool ReflectionProbe::_setEnabled(void *object, const char *index, const char *d
ReflectionProbe* probe = reinterpret_cast< ReflectionProbe* >(object);
probe->mEnabled = dAtob(data);
probe->setMaskBits(-1);
probe->setMaskBits(EnabledMask);
return true;
}
@ -219,6 +216,7 @@ bool ReflectionProbe::_doBake(void *object, const char *index, const char *data)
ReflectionProbe* probe = reinterpret_cast< ReflectionProbe* >(object);
probe->bake();
probe->setMaskBits(StaticDataMask);
return false;
}
@ -240,6 +238,7 @@ bool ReflectionProbe::_setRadius(void *object, const char *index, const char *da
return false;
probe->mObjScale = Point3F(probe->mRadius, probe->mRadius, probe->mRadius);
probe->setMaskBits(StaticDataMask);
return true;
}
@ -259,6 +258,8 @@ bool ReflectionProbe::_setReflectionMode(void *object, const char *index, const
probe->mCubemapName = "";
}
probe->setMaskBits(StaticDataMask);
return true;
}
@ -307,6 +308,7 @@ void ReflectionProbe::onRemove()
if (isClientObject())
{
PROBEMGR->unregisterProbe(mProbeInfo->mProbeIdx);
mProbeInfo = nullptr;
}
// Remove this object from the scene
@ -342,15 +344,17 @@ void ReflectionProbe::setTransform(const MatrixF & mat)
{
// Let SceneObject handle all of the matrix manipulation
if (!mEditPosOffset)
{
Parent::setTransform(mat);
setMaskBits(TransformMask);
}
else
{
mProbeRefOffset = mat.getPosition();
setMaskBits(StaticDataMask);
}
mDirty = true;
// Dirty our network mask so that the new transform gets
// transmitted to the client object
setMaskBits(TransformMask);
}
const MatrixF& ReflectionProbe::getTransform() const
@ -369,15 +373,17 @@ const MatrixF& ReflectionProbe::getTransform() const
void ReflectionProbe::setScale(const VectorF &scale)
{
if (!mEditPosOffset)
{
Parent::setScale(scale);
setMaskBits(TransformMask);
}
else
{
mProbeRefScale = scale;
setMaskBits(StaticDataMask);
}
mDirty = true;
// Dirty our network mask so that the new transform gets
// transmitted to the client object
setMaskBits(TransformMask);
}
const VectorF& ReflectionProbe::getScale() const
@ -495,6 +501,8 @@ void ReflectionProbe::updateProbeParams()
if (!mProbeInfo)
return;
mProbeInfo->mIsEnabled = mEnabled;
mProbeInfo->mProbeShapeType = mProbeShapeType;
if (mProbeShapeType == ProbeRenderInst::Sphere)
@ -553,6 +561,8 @@ void ReflectionProbe::updateProbeParams()
{
if (mReflectionModeType == StaticCubemap)
processStaticCubemap();
else if (mReflectionModeType == BakedCubemap)
processBakedCubemap();
else
processDynamicCubemap();
}
@ -562,61 +572,16 @@ void ReflectionProbe::updateProbeParams()
void ReflectionProbe::processDynamicCubemap()
{
if (!mProbeInfo)
//if (!mProbeInfo)
return;
mEnabled = false;
if (mReflectionModeType != DynamicCubemap)
if (mReflectionModeType == DynamicCubemap && !mDynamicCubemap.isNull())
{
mProbeInfo->mCubeReflector.unregisterReflector();
mProbeInfo->mPrefilterCubemap = mDynamicCubemap;
if ((mReflectionModeType == BakedCubemap) && !mProbeUniqueID.isEmpty())
{
String irrPath = getIrradianceMapPath();
if (Platform::isFile(irrPath))
{
mIrridianceMap->setCubemapFile(FileName(irrPath));
//mIrridianceMap->updateFaces();
}
if (mIrridianceMap == nullptr || mIrridianceMap->mCubemap.isNull())
{
Con::errorf("ReflectionProbe::processDynamicCubemap() - Unable to load baked irradiance map at %s", getIrradianceMapPath().c_str());
return;
}
String prefilPath = getPrefilterMapPath();
if (Platform::isFile(prefilPath))
{
mPrefilterMap->setCubemapFile(FileName(prefilPath));
//mPrefilterMap->updateFaces();
}
if (mPrefilterMap == nullptr || mPrefilterMap->mCubemap.isNull())
{
Con::errorf("ReflectionProbe::processDynamicCubemap() - Unable to load baked prefilter map at %s", getPrefilterMapPath().c_str());
return;
}
//mProbeInfo->mPrefilterCubemap = mPrefilterMap->mCubemap;
//mProbeInfo->mIrradianceCubemap = mIrridianceMap->mCubemap;
mEnabled = true;
}
}
else
{
if (mReflectionModeType == DynamicCubemap && !mDynamicCubemap.isNull())
{
mProbeInfo->mPrefilterCubemap = mDynamicCubemap;
mProbeInfo->mCubeReflector.registerReflector(this, reflectorDesc); //need to decide how we wanna do the reflectorDesc. static name or a field
}
else
{
mEnabled = false;
}
//mCubeReflector.registerReflector(this, reflectorDesc); //need to decide how we wanna do the reflectorDesc. static name or a field
}
if (mEnabled)
@ -629,12 +594,61 @@ void ReflectionProbe::processDynamicCubemap()
// PROBEMGR->updateProbeTexture(mProbeInfo->mProbeIdx);
}
void ReflectionProbe::processBakedCubemap()
{
if (!mProbeInfo)
return;
mProbeInfo->mIsEnabled = false;
if ((mReflectionModeType != BakedCubemap) || mProbeUniqueID.isEmpty())
return;
String irrPath = getIrradianceMapPath();
if (Platform::isFile(irrPath))
{
mIrridianceMap->setCubemapFile(FileName(irrPath));
mIrridianceMap->updateFaces();
}
if (mIrridianceMap == nullptr || mIrridianceMap->mCubemap.isNull())
{
Con::errorf("ReflectionProbe::processDynamicCubemap() - Unable to load baked irradiance map at %s", getIrradianceMapPath().c_str());
return;
}
String prefilPath = getPrefilterMapPath();
if (Platform::isFile(prefilPath))
{
mPrefilterMap->setCubemapFile(FileName(prefilPath));
mPrefilterMap->updateFaces();
}
if (mPrefilterMap == nullptr || mPrefilterMap->mCubemap.isNull())
{
Con::errorf("ReflectionProbe::processDynamicCubemap() - Unable to load baked prefilter map at %s", getPrefilterMapPath().c_str());
return;
}
mProbeInfo->mPrefilterCubemap = mPrefilterMap->mCubemap;
mProbeInfo->mIrradianceCubemap = mIrridianceMap->mCubemap;
if (mEnabled && mProbeInfo->mPrefilterCubemap->isInitialized() && mProbeInfo->mIrradianceCubemap->isInitialized())
{
mProbeInfo->mIsEnabled = true;
//Update the probe manager with our new texture!
if (!mProbeInfo->mIsSkylight)
PROBEMGR->updateProbeTexture(mProbeInfo->mProbeIdx);
}
}
void ReflectionProbe::processStaticCubemap()
{
if (!mProbeInfo)
return;
mEnabled = false;
mProbeInfo->mIsEnabled = false;
String path = Con::getVariable("$pref::ReflectionProbes::CurrentLevelPath", "levels/");
@ -709,17 +723,16 @@ void ReflectionProbe::processStaticCubemap()
{
mProbeInfo->mPrefilterCubemap = mPrefilterMap->mCubemap;
mProbeInfo->mIrradianceCubemap = mIrridianceMap->mCubemap;
mEnabled = true;
}
if (mEnabled)
if (mEnabled && mProbeInfo->mPrefilterCubemap->isInitialized() && mProbeInfo->mIrradianceCubemap->isInitialized())
{
mProbeInfo->mIsEnabled = true;
else
mProbeInfo->mIsEnabled = false;
//Update the probe manager with our new texture!
if (!mProbeInfo->mIsSkylight && mProbeInfo->mPrefilterCubemap->isInitialized() && mProbeInfo->mIrradianceCubemap->isInitialized())
PROBEMGR->updateProbeTexture(mProbeInfo->mProbeIdx);
//Update the probe manager with our new texture!
if (!mProbeInfo->mIsSkylight)
PROBEMGR->updateProbeTexture(mProbeInfo->mProbeIdx);
}
}
bool ReflectionProbe::createClientResources()
@ -791,7 +804,7 @@ String ReflectionProbe::getIrradianceMapPath()
void ReflectionProbe::bake()
{
if (mReflectionModeType == DynamicCubemap)
if (mReflectionModeType != BakedCubemap)
return;
PROBEMGR->bakeProbe(this);

View file

@ -118,6 +118,9 @@ protected:
U32 cubeDescId;
ReflectorDesc *reflectorDesc;
//Utilized in dynamic reflections
//CubeReflector mCubeReflector;
///Prevents us from saving out the cubemaps(for now) but allows us the full HDR range on the in-memory cubemap captures
bool mUseHDRCaptures;
@ -221,6 +224,7 @@ public:
bool createClientResources();
void processDynamicCubemap();
void processBakedCubemap();
void processStaticCubemap();
// This is the function that allows this object to submit itself for rendering

View file

@ -143,6 +143,9 @@ void Skylight::unpackUpdate(NetConnection *conn, BitStream *stream)
void Skylight::updateProbeParams()
{
if (!mProbeInfo)
return;
mProbeShapeType = ProbeRenderInst::Skylight;
Parent::updateProbeParams();
}

View file

@ -139,6 +139,9 @@ void SphereEnvironmentProbe::unpackUpdate(NetConnection *conn, BitStream *stream
void SphereEnvironmentProbe::updateProbeParams()
{
if (!mProbeInfo)
return;
mProbeShapeType = ProbeRenderInst::Sphere;
Parent::updateProbeParams();
}

View file

@ -415,6 +415,8 @@ void RenderProbeMgr::_setupStaticParameters()
mEffectiveProbeCount = 0;
mMipCount = 0;
mHasSkylight = false;
if (probePositionsData.size() != MAXPROBECOUNT)
{
probePositionsData.setSize(MAXPROBECOUNT);

View file

@ -77,9 +77,6 @@ struct ProbeRenderInst
GFXCubemapHandle mPrefilterCubemap;
GFXCubemapHandle mIrradianceCubemap;
//Utilized in dynamic reflections
CubeReflector mCubeReflector;
/// The priority of this light used for
/// light and shadow scoring.
F32 mPriority;

View file

@ -1,126 +1,123 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<EditorSettings>
<Group name="WorldEditor">
<Setting name="forceLoadDAE">0</Setting>
<Setting name="orthoShowGrid">1</Setting>
<Setting name="dropType">screenCenter</Setting>
<Setting name="displayType">6</Setting>
<Setting name="currentEditor">WorldEditorInspectorPlugin</Setting>
<Setting name="undoLimit">40</Setting>
<Setting name="orthoFOV">50</Setting>
<Setting name="torsionPath">AssetWork_Debug.exe</Setting>
<Group name="ObjectIcons">
<Setting name="fadeIconsStartDist">8</Setting>
<Setting name="fadeIcons">1</Setting>
<Setting name="fadeIconsEndAlpha">0</Setting>
<Setting name="fadeIconsStartAlpha">255</Setting>
<Setting name="fadeIconsEndDist">20</Setting>
</Group>
<Group name="Docs">
<Setting name="documentationReference">../../../Documentation/Torque 3D - Script Manual.chm</Setting>
<Setting name="documentationURL">http://www.garagegames.com/products/torque-3d/documentation/user</Setting>
<Setting name="documentationLocal">../../../Documentation/Official Documentation.html</Setting>
<Setting name="forumURL">http://www.garagegames.com/products/torque-3d/forums</Setting>
</Group>
<Group name="Render">
<Setting name="renderObjText">1</Setting>
<Setting name="showMousePopupInfo">1</Setting>
<Setting name="renderSelectionBox">1</Setting>
<Setting name="renderPopupBackground">1</Setting>
<Setting name="renderObjHandle">1</Setting>
</Group>
<Group name="Grid">
<Setting name="gridOriginColor">255 255 255 100</Setting>
<Setting name="gridSnap">0</Setting>
<Setting name="gridMinorColor">51 51 51 100</Setting>
<Setting name="gridColor">102 102 102 100</Setting>
<Setting name="gridSize">1</Setting>
</Group>
<Group name="Tools">
<Setting name="snapSoftSize">2</Setting>
<Setting name="snapSoft">0</Setting>
<Setting name="boundingBoxCollision">0</Setting>
<Setting name="dropAtScreenCenterScalar">1</Setting>
<Setting name="objectsUseBoxCenter">1</Setting>
<Setting name="snapGround">0</Setting>
<Setting name="dropAtScreenCenterMax">100</Setting>
</Group>
<Group name="Theme">
<Setting name="windowTitleBGHLColor">48 48 48 255</Setting>
<Setting name="windowTitleFontColor">215 215 215 255</Setting>
<Setting name="windowTitleBGNAColor">180 180 180 255</Setting>
<Setting name="windowTitleFontHLColor">255 255 255 255</Setting>
<Setting name="windowTitleBGColor">50 50 50 255</Setting>
</Group>
<Group name="Color">
<Setting name="objMouseOverSelectColor">0 0 255 255</Setting>
<Setting name="objMouseOverColor">0 255 0 255</Setting>
<Setting name="objSelectColor">255 0 0 255</Setting>
<Setting name="dragRectColor">255 255 0 255</Setting>
<Setting name="popupBackgroundColor">100 100 100 255</Setting>
<Setting name="objectTextColor">255 255 255 255</Setting>
<Setting name="selectionBoxColor">255 255 0 255</Setting>
</Group>
<Group name="Images">
<Setting name="selectHandle">tools/worldEditor/images/SelectHandle</Setting>
<Setting name="lockedHandle">tools/worldEditor/images/LockedHandle</Setting>
<Setting name="defaultHandle">tools/worldEditor/images/DefaultHandle</Setting>
</Group>
</Group>
<Group name="GuiEditor">
<Setting name="previewResolution">1024 768</Setting>
<Setting name="lastPath">tools/gui</Setting>
<Group name="EngineDevelopment">
<Setting name="showEditorProfiles">0</Setting>
<Setting name="toggleIntoEditor">0</Setting>
<Setting name="showEditorGuis">0</Setting>
</Group>
<Group name="Snapping">
<Setting name="snapToCanvas">1</Setting>
<Setting name="snapToGuides">1</Setting>
<Setting name="snapToCenters">1</Setting>
<Setting name="snapToControls">1</Setting>
<Setting name="snap2GridSize">8</Setting>
<Setting name="sensitivity">2</Setting>
<Setting name="snapToEdges">1</Setting>
<Setting name="snap2Grid">0</Setting>
</Group>
<Group name="Help">
<Setting name="documentationReference">../../../Documentation/Torque 3D - Script Manual.chm</Setting>
<Setting name="documentationLocal">../../../Documentation/Official Documentation.html</Setting>
<Setting name="documentationURL">http://www.garagegames.com/products/torque-3d/documentation/user</Setting>
</Group>
<Group name="Rendering">
<Setting name="drawGuides">1</Setting>
<Setting name="drawBorderLines">1</Setting>
</Group>
<Group name="Library">
<Setting name="viewType">Categorized</Setting>
</Group>
<Group name="Selection">
<Setting name="fullBox">0</Setting>
</Group>
</Group>
<Group name="AxisGizmo">
<Setting name="mouseScaleScalar">0.8</Setting>
<Setting name="renderWhenUsed">0</Setting>
<Setting name="renderInfoText">1</Setting>
<Setting name="axisGizmoMaxScreenLen">100</Setting>
<Setting name="rotationSnap">15</Setting>
<Setting name="snapRotations">0</Setting>
<Setting name="mouseRotateScalar">0.8</Setting>
<Setting name="mouseScaleScalar">0.8</Setting>
<Group name="Grid">
<Setting name="renderPlane">0</Setting>
<Setting name="gridColor">255 255 255 20</Setting>
<Setting name="planeDim">500</Setting>
<Setting name="renderPlaneHashes">0</Setting>
<Setting name="snapToGrid">0</Setting>
<Setting name="gridColor">255 255 255 20</Setting>
<Setting name="gridSize">10 10 10</Setting>
<Setting name="snapToGrid">0</Setting>
</Group>
</Group>
<Group name="WorldEditor">
<Setting name="undoLimit">40</Setting>
<Setting name="orthoFOV">50</Setting>
<Setting name="displayType">6</Setting>
<Setting name="forceLoadDAE">0</Setting>
<Setting name="orthoShowGrid">1</Setting>
<Setting name="dropType">screenCenter</Setting>
<Setting name="currentEditor">WorldEditorInspectorPlugin</Setting>
<Setting name="torsionPath">AssetWork_Debug.exe</Setting>
<Group name="Grid">
<Setting name="gridColor">102 102 102 100</Setting>
<Setting name="gridOriginColor">255 255 255 100</Setting>
<Setting name="gridMinorColor">51 51 51 100</Setting>
<Setting name="gridSize">1</Setting>
<Setting name="gridSnap">0</Setting>
</Group>
<Group name="Color">
<Setting name="objSelectColor">255 0 0 255</Setting>
<Setting name="objectTextColor">255 255 255 255</Setting>
<Setting name="objMouseOverSelectColor">0 0 255 255</Setting>
<Setting name="objMouseOverColor">0 255 0 255</Setting>
<Setting name="dragRectColor">255 255 0 255</Setting>
<Setting name="popupBackgroundColor">100 100 100 255</Setting>
<Setting name="selectionBoxColor">255 255 0 255</Setting>
</Group>
<Group name="Render">
<Setting name="renderObjHandle">1</Setting>
<Setting name="renderSelectionBox">1</Setting>
<Setting name="renderPopupBackground">1</Setting>
<Setting name="showMousePopupInfo">1</Setting>
<Setting name="renderObjText">1</Setting>
</Group>
<Group name="Tools">
<Setting name="dropAtScreenCenterMax">100</Setting>
<Setting name="snapSoft">0</Setting>
<Setting name="snapGround">0</Setting>
<Setting name="dropAtScreenCenterScalar">1</Setting>
<Setting name="snapSoftSize">2</Setting>
<Setting name="objectsUseBoxCenter">1</Setting>
<Setting name="boundingBoxCollision">0</Setting>
</Group>
<Group name="ObjectIcons">
<Setting name="fadeIconsStartDist">8</Setting>
<Setting name="fadeIconsEndDist">20</Setting>
<Setting name="fadeIconsStartAlpha">255</Setting>
<Setting name="fadeIconsEndAlpha">0</Setting>
<Setting name="fadeIcons">1</Setting>
</Group>
<Group name="Docs">
<Setting name="documentationLocal">../../../Documentation/Official Documentation.html</Setting>
<Setting name="documentationURL">http://www.garagegames.com/products/torque-3d/documentation/user</Setting>
<Setting name="documentationReference">../../../Documentation/Torque 3D - Script Manual.chm</Setting>
<Setting name="forumURL">http://www.garagegames.com/products/torque-3d/forums</Setting>
</Group>
<Group name="Images">
<Setting name="lockedHandle">tools/worldEditor/images/LockedHandle</Setting>
<Setting name="selectHandle">tools/worldEditor/images/SelectHandle</Setting>
<Setting name="defaultHandle">tools/worldEditor/images/DefaultHandle</Setting>
</Group>
<Group name="Theme">
<Setting name="windowTitleBGColor">50 50 50 255</Setting>
<Setting name="windowTitleBGHLColor">48 48 48 255</Setting>
<Setting name="windowTitleBGNAColor">180 180 180 255</Setting>
<Setting name="windowTitleFontColor">215 215 215 255</Setting>
<Setting name="windowTitleFontHLColor">255 255 255 255</Setting>
</Group>
</Group>
<Group name="GuiEditor">
<Setting name="lastPath">tools/gui</Setting>
<Setting name="previewResolution">1024 768</Setting>
<Group name="Help">
<Setting name="documentationURL">http://www.garagegames.com/products/torque-3d/documentation/user</Setting>
<Setting name="documentationLocal">../../../Documentation/Official Documentation.html</Setting>
<Setting name="documentationReference">../../../Documentation/Torque 3D - Script Manual.chm</Setting>
</Group>
<Group name="Snapping">
<Setting name="sensitivity">2</Setting>
<Setting name="snapToCenters">1</Setting>
<Setting name="snap2Grid">0</Setting>
<Setting name="snap2GridSize">8</Setting>
<Setting name="snapToGuides">1</Setting>
<Setting name="snapToEdges">1</Setting>
<Setting name="snapToControls">1</Setting>
<Setting name="snapToCanvas">1</Setting>
</Group>
<Group name="Library">
<Setting name="viewType">Categorized</Setting>
</Group>
<Group name="EngineDevelopment">
<Setting name="showEditorGuis">0</Setting>
<Setting name="toggleIntoEditor">0</Setting>
<Setting name="showEditorProfiles">0</Setting>
</Group>
<Group name="Rendering">
<Setting name="drawGuides">1</Setting>
<Setting name="drawBorderLines">1</Setting>
</Group>
<Group name="Selection">
<Setting name="fullBox">0</Setting>
</Group>
</Group>
<Group name="NavEditor">
<Setting name="SpawnClass">AIPlayer</Setting>
</Group>
<Group name="LevelInformation">
<Setting name="levelsDirectory">data/FPSGameplay/levels</Setting>
<Group name="levels">
@ -132,4 +129,7 @@
<Group name="ConvexEditor">
<Setting name="materialName">Grid_512_Orange</Setting>
</Group>
<Group name="NavEditor">
<Setting name="SpawnClass">AIPlayer</Setting>
</Group>
</EditorSettings>