hook up attenuation value. todo: sort networkjing properly

This commit is contained in:
Azaezel 2019-03-21 23:47:01 -05:00
parent 8595e273a4
commit ead78ec588
5 changed files with 21 additions and 79 deletions

View file

@ -78,6 +78,7 @@ BoxEnvironmentProbe::BoxEnvironmentProbe() : ReflectionProbe()
{
mCaptureMask = REFLECTION_PROBE_CAPTURE_TYPEMASK;
mProbeShapeType = ProbeRenderInst::Box;
mAtten = 0.0;
}
BoxEnvironmentProbe::~BoxEnvironmentProbe()
@ -92,6 +93,8 @@ void BoxEnvironmentProbe::initPersistFields()
// SceneObject already handles exposing the transform
Parent::initPersistFields();
addField("attenuation", TypeF32, Offset(mAtten, BoxEnvironmentProbe), "falloff percent");
removeField("radius");
}
@ -136,6 +139,11 @@ U32 BoxEnvironmentProbe::packUpdate(NetConnection *conn, U32 mask, BitStream *st
// Allow the Parent to get a crack at writing its info
U32 retMask = Parent::packUpdate(conn, mask, stream);
if (stream->writeFlag(mask & UpdateMask))
{
stream->write(mAtten);
}
return retMask;
}
@ -143,6 +151,11 @@ void BoxEnvironmentProbe::unpackUpdate(NetConnection *conn, BitStream *stream)
{
// Let the Parent read any info it sent
Parent::unpackUpdate(conn, stream);
if (stream->readFlag()) // UpdateMask
{
stream->read(&mAtten);
}
}
//-----------------------------------------------------------------------------
@ -154,79 +167,9 @@ void BoxEnvironmentProbe::updateProbeParams()
Parent::updateProbeParams();
mProbeInfo->mProbeShapeType = ProbeRenderInst::Box;
mProbeInfo->mAtten = mAtten;
}
/*void BoxEnvironmentProbe::prepRenderImage(SceneRenderState *state)
{
if (!mEnabled || !ReflectionProbe::smRenderPreviewProbes)
return;
if (ReflectionProbe::smRenderPreviewProbes && gEditingMission && mEditorShapeInst && mPrefilterMap != nullptr)
{
GFXTransformSaver saver;
// Calculate the distance of this object from the camera
Point3F cameraOffset;
getRenderTransform().getColumn(3, &cameraOffset);
cameraOffset -= state->getDiffuseCameraPosition();
F32 dist = cameraOffset.len();
if (dist < 0.01f)
dist = 0.01f;
// Set up the LOD for the shape
F32 invScale = (1.0f / getMax(getMax(mObjScale.x, mObjScale.y), mObjScale.z));
mEditorShapeInst->setDetailFromDistance(state, dist * invScale);
// Make sure we have a valid level of detail
if (mEditorShapeInst->getCurrentDetail() < 0)
return;
BaseMatInstance* probePrevMat = mEditorShapeInst->getMaterialList()->getMaterialInst(0);
setPreviewMatParameters(state, probePrevMat);
// GFXTransformSaver is a handy helper class that restores
// the current GFX matrices to their original values when
// it goes out of scope at the end of the function
// Set up our TS render state
TSRenderState rdata;
rdata.setSceneState(state);
rdata.setFadeOverride(1.0f);
// We might have some forward lit materials
// so pass down a query to gather lights.
LightQuery query;
query.init(getWorldSphere());
rdata.setLightQuery(&query);
// Set the world matrix to the objects render transform
MatrixF mat = getRenderTransform();
mat.scale(Point3F(1, 1, 1));
GFX->setWorldMatrix(mat);
// Animate the the shape
mEditorShapeInst->animate();
// Allow the shape to submit the RenderInst(s) for itself
mEditorShapeInst->render(rdata);
saver.restore();
}
// If the light is selected or light visualization
// is enabled then register the callback.
const bool isSelectedInEditor = (gEditingMission && isSelected());
if (isSelectedInEditor)
{
ObjectRenderInst *ri = state->getRenderPass()->allocInst<ObjectRenderInst>();
ri->renderDelegate.bind(this, &ReflectionProbe::_onRenderViz);
ri->type = RenderPassManager::RIT_Editor;
state->getRenderPass()->addInst(ri);
}
}*/
void BoxEnvironmentProbe::setPreviewMatParameters(SceneRenderState* renderState, BaseMatInstance* mat)
{
Parent::setPreviewMatParameters(renderState, mat);