FIRE-33613: [OpenSim] [PBR] Camera cannot be located at negative Z

- mitigate SL-20206 Underwater visuals problematic when camera is swung below Z=0
- add support for `OpenSimExtras.MinSimHeight` Simulation Feature to `LLViewerRegion`
- apply region minimum simulation height as gruond plane for camera minZ constraints
meow-7.2.2
tim 2024-05-16 16:25:05 -04:00
parent 257e9b30d6
commit f918c1d437
3 changed files with 22 additions and 3 deletions

View File

@ -2145,10 +2145,21 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
}
// [/RLVa:KB]
// <FS:humbletim> FIRE-33613: [OpenSim] [PBR] Camera cannot be located at negative Z
F32 camera_ground_plane = F_ALMOST_ZERO;
#ifdef OPENSIM
// integrate OpenSimExtras.MinSimHeight into the camera ground plane calculation
if (auto regionp = LLWorld::getInstance()->getRegionFromPosGlobal(camera_position_global))
{
camera_ground_plane += regionp->getMinSimHeight();
}
#endif
// </FS:humbletim>
// Don't let camera go underground
F32 camera_min_off_ground = getCameraMinOffGround();
camera_land_height = LLWorld::getInstance()->resolveLandHeightGlobal(camera_position_global);
F32 minZ = llmax(F_ALMOST_ZERO, camera_land_height + camera_min_off_ground);
F32 minZ = llmax(camera_ground_plane, camera_land_height + camera_min_off_ground);
if (camera_position_global.mdV[VZ] < minZ)
{
camera_position_global.mdV[VZ] = minZ;

View File

@ -675,7 +675,8 @@ LLViewerRegion::LLViewerRegion(const U64 &handle,
// </FS:Beq>
// <FS:CR> Aurora Sim
mWidth(region_width_meters),
mWidthScaleFactor(region_width_meters / REGION_WIDTH_METERS) // <FS:Ansariel> FIRE-19563: Scaling for OpenSim VarRegions
mWidthScaleFactor(region_width_meters / REGION_WIDTH_METERS), // <FS:Ansariel> FIRE-19563: Scaling for OpenSim VarRegions
mMinSimHeight(0.f) // <FS:humbletim> FIRE-33613: [OpenSim] [PBR] Camera cannot be located at negative Z
{
// Moved this up... -> mWidth = region_width_meters;
// </FS:CR>
@ -2632,6 +2633,11 @@ void LLViewerRegion::setSimulatorFeatures(const LLSD& sim_features)
mMaxTEs = LLAvatarAppearanceDefines::ETextureIndex::TEX_NUM_INDICES;
#endif // OPENSIM
// </FS:Beq>
// <FS:humbletim> FIRE-33613: [OpenSim] [PBR] Camera cannot be located at negative Z
#ifdef OPENSIM
mMinSimHeight = !mSimulatorFeatures.has("OpenSimExtras") ? 0.0f : mSimulatorFeatures["OpenSimExtras"]["MinSimHeight"].asReal();
#endif
// </FS:humbletim>
}
//this is called when the parent is not cacheable.

View File

@ -249,6 +249,7 @@ public:
F32 getWidth() const { return mWidth; }
F32 getWidthScaleFactor() const { return mWidthScaleFactor; } // <FS:Ansariel> FIRE-19563: Scaling for OpenSim VarRegions
F32 getMinSimHeight() const { return mMinSimHeight; } // <FS:humbletim/> FIRE-33613: [OpenSim] [PBR] Camera cannot be located at negative Z
// regions are expensive to release, this function gradually releases cache from memory
static void idleCleanup(F32 max_update_time);
@ -548,7 +549,8 @@ public:
S32 mLastUpdate; //last time called idleUpdate()
F32 mWidthScaleFactor; // <FS:Ansariel> FIRE-19563: Scaling for OpenSim VarRegions
S32 mMaxBakes; // <FS:Beq/> store max bakes on the region
S32 mMaxTEs; // <FS:Beq/> store max bakes on the region
S32 mMaxTEs; // <FS:Beq/> store max texture entries on the region
F32 mMinSimHeight; // <FS:humbletim/> FIRE-33613: [OpenSim] [PBR] Camera cannot be located at negative Z
// simulator name
std::string mName;
std::string mZoning;