Temporary data model shenanigans.

Should help tweak and tune placement with direct community guidance.
DRTVWR-583
master
Jonathan "Geenz" Goodman 2023-09-01 08:28:57 -07:00
parent 348d427db6
commit 32d1984bf9
7 changed files with 107 additions and 32 deletions

View File

@ -109,16 +109,16 @@ void LLHeroProbeManager::update()
// Get the nearest hero.
float distance = F32_MAX;
if (mNearestHero.notNull())
if (mNearestHero != nullptr)
{
distance = mNearestHero->mDistanceWRTCamera;
distance = mNearestHero->mDrawable->mDistanceWRTCamera;
}
for (auto drawable : mHeroList)
for (auto drawable : mHeroVOList)
{
if (drawable.notNull() && drawable != mNearestHero)
if (drawable != nullptr && drawable != mNearestHero && drawable->mDrawable.notNull())
{
if (drawable->mDistanceWRTCamera < distance)
if (drawable->mDrawable->mDistanceWRTCamera < distance)
{
mIsInTransition = true;
mNearestHero = drawable;
@ -133,8 +133,41 @@ void LLHeroProbeManager::update()
}
else
{
if (mNearestHero.notNull())
probe_pos.set(mNearestHero->mXform.getPosition().mV[0], mNearestHero->mXform.getPosition().mV[1], camera_pos.mV[2]);
if (mNearestHero != nullptr && mNearestHero->mDrawable.notNull())
{
LLVector3 hero_pos = mNearestHero->mDrawable->mXform.getPosition();
switch (mNearestHero->mirrorPlacementMode()) {
case 0:
probe_pos.set(camera_pos.mV[0], hero_pos.mV[1], hero_pos.mV[2]);
break;
case 1:
probe_pos.set(hero_pos.mV[0], camera_pos.mV[1], hero_pos.mV[2]);
break;
case 2:
probe_pos.set(hero_pos.mV[0], hero_pos.mV[1], camera_pos.mV[2]);
break;
case 3:
// Find the nearest point relative to the camera on the VOVolume.
LLVector4a hit_pos;
bool hit = mNearestHero->lineSegmentIntersect(LLVector4a(camera_pos.mV[0], camera_pos.mV[1], camera_pos.mV[2]),
LLVector4a(hero_pos.mV[0], hero_pos.mV[1], hero_pos.mV[2]),
-1,
FALSE,
FALSE,
FALSE,
NULL,
&hit_pos);
if (hit)
probe_pos = hit_pos;
break;
}
}
if (mHeroProbeStrength < 1.f)
@ -505,7 +538,7 @@ void LLHeroProbeManager::cleanup()
glDeleteBuffers(1, &mUBO);
mUBO = 0;
mHeroList.clear();
mHeroVOList.clear();
mNearestHero = nullptr;
}
@ -523,18 +556,19 @@ void LLHeroProbeManager::doOcclusion()
}
}
void LLHeroProbeManager::registerHeroDrawable(LLDrawable* drawablep)
void LLHeroProbeManager::registerHeroDrawable(LLVOVolume* drawablep)
{
if (mHeroList.find(drawablep) == mHeroList.end())
{
mHeroList.insert(drawablep);
}
if (mHeroVOList.find(drawablep) == mHeroVOList.end())
{
mHeroVOList.insert(drawablep);
LL_INFOS() << "Mirror drawable registered." << LL_ENDL;
}
}
void LLHeroProbeManager::unregisterHeroDrawable(LLDrawable *drawablep)
void LLHeroProbeManager::unregisterHeroDrawable(LLVOVolume* drawablep)
{
if (mHeroList.find(drawablep) != mHeroList.end())
if (mHeroVOList.find(drawablep) != mHeroVOList.end())
{
mHeroList.erase(drawablep);
mHeroVOList.erase(drawablep);
}
}

View File

@ -68,8 +68,8 @@ public:
// perform occlusion culling on all active reflection probes
void doOcclusion();
void registerHeroDrawable(LLDrawable* drawablep);
void unregisterHeroDrawable(LLDrawable* drawablep);
void registerHeroDrawable(LLVOVolume* drawablep);
void unregisterHeroDrawable(LLVOVolume* drawablep);
private:
friend class LLPipeline;
@ -128,7 +128,7 @@ private:
// if true, reset all probe render state on the next update (for teleports and sky changes)
bool mReset = false;
LLDrawable::ordered_drawable_set_t mHeroList;
LLPointer<LLDrawable> mNearestHero;
std::set<LLVOVolume*> mHeroVOList;
LLVOVolume* mNearestHero;
};

View File

@ -755,10 +755,6 @@ void LLPanelVolume::sendIsMirror()
}
LLVOVolume *volobjp = (LLVOVolume *)objectp;
// Quick hack to set the mirror locally.
gPipeline.mHeroProbeManager.registerHeroDrawable(volobjp->mDrawable);
BOOL value = getChild<LLUICtrl>("Mirror Checkbox Ctrl")->getValue();
volobjp->setIsMirror(value);
LL_INFOS() << "update mirror sent" << LL_ENDL;

View File

@ -1524,11 +1524,43 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
std::string temp_string;
mesgsys->getStringFast(_PREHASH_ObjectData, _PREHASH_Text, temp_string, block_num );
std::stringstream ss(temp_string);
std::string word;
bool mirror_detected = false;
while (ss >> word)
{
if (word == "Mirror")
{
mirror_detected = true;
mIsMirror = true;
}
else if (word == "XAlign" && mIsMirror)
{
mMirrorPlacementMode = 0;
}
else if (word == "YAlign" && mIsMirror)
{
mMirrorPlacementMode = 1;
}
else if (word == "ZAlign" && mIsMirror)
{
mMirrorPlacementMode = 2;
}
else if (word == "NearestPoint" && mIsMirror)
{
mMirrorPlacementMode = 3;
}
}
LLColor4U coloru;
mesgsys->getBinaryDataFast(_PREHASH_ObjectData, _PREHASH_TextColor, coloru.mV, 4, block_num);
// alpha was flipped so that it zero encoded better
coloru.mV[3] = 255 - coloru.mV[3];
if (mirror_detected)
coloru.mV[3] = 0;
mText->setColor(LLColor4(coloru));
mText->setString(temp_string);

View File

@ -258,6 +258,7 @@ public:
virtual BOOL hasLightTexture() const { return FALSE; }
virtual BOOL isReflectionProbe() const { return FALSE; }
virtual BOOL isMirror() const { return FALSE; }
virtual U8 mirrorPlacementMode() const { return 0; }
// This method returns true if the object is over land owned by
// the agent, one of its groups, or it encroaches and
@ -878,6 +879,9 @@ protected:
F32 mPhysicsCost;
F32 mLinksetPhysicsCost;
bool mIsMirror;
U8 mMirrorPlacementMode;
// If true, "shrink wrap" this volume in its spatial partition. See "shrinkWrap"
bool mShouldShrinkWrap = false;

View File

@ -249,6 +249,9 @@ LLVOVolume::~LLVOVolume()
mTextureAnimp = NULL;
delete mVolumeImpl;
mVolumeImpl = NULL;
if (mIsMirror)
gPipeline.mHeroProbeManager.unregisterHeroDrawable(this);
gMeshRepo.unregisterMesh(this);
@ -1045,9 +1048,9 @@ LLDrawable *LLVOVolume::createDrawable(LLPipeline *pipeline)
updateReflectionProbePtr();
}
//if (isMirror())
if (isMirror())
{
gPipeline.mHeroProbeManager.registerHeroDrawable(mDrawable);
gPipeline.mHeroProbeManager.registerHeroDrawable(this);
}
updateRadius();
@ -3396,17 +3399,22 @@ void LLVOVolume::updateMirrorDrawable()
{
if (isMirror())
{
gPipeline.mHeroProbeManager.registerHeroDrawable(mDrawable);
gPipeline.mHeroProbeManager.registerHeroDrawable(this);
}
else
{
gPipeline.mHeroProbeManager.unregisterHeroDrawable(mDrawable);
gPipeline.mHeroProbeManager.unregisterHeroDrawable(this);
}
}
BOOL LLVOVolume::isMirror() const
{
return getParameterEntryInUse(LLNetworkData::PARAMS_REFLECTION_PROBE);
return mIsMirror;
}
U8 LLVOVolume::mirrorPlacementMode() const
{
return mMirrorPlacementMode;
}
BOOL LLVOVolume::isReflectionProbe() const
@ -4461,9 +4469,9 @@ void LLVOVolume::parameterChanged(U16 param_type, LLNetworkData* data, BOOL in_u
updateReflectionProbePtr();
if (isMirror())
gPipeline.mHeroProbeManager.registerHeroDrawable(mDrawable);
gPipeline.mHeroProbeManager.registerHeroDrawable(this);
else
gPipeline.mHeroProbeManager.unregisterHeroDrawable(mDrawable);
gPipeline.mHeroProbeManager.unregisterHeroDrawable(this);
}
void LLVOVolume::updateReflectionProbePtr()

View File

@ -298,6 +298,7 @@ public:
// Mirrors
bool setIsMirror(BOOL is_mirror);
void updateMirrorDrawable();
U8 mirrorPlacementMode() const override;
// Reflection Probes
bool setIsReflectionProbe(BOOL is_probe);