I've recently had a problem with RenderingDistance (with SCALEd Nodes), so I'm gonna clear my point and do a Request For Comments.
I don't agree with the policy to make the renderingDistance dependent from the MovableObject's SCALE (as it is now), I really think it should be simpler and just check if current distance from camera is lesser than renderingDistance (if it has been set - so if its value is greater than zero).
My point is that Ogre shouldn't consider MovableObject's SCALE, it should simply check the rendering Distance (code from beginning of MovableObject::_notifyCurrentCamera(Camera* cam), modified commenting out what is incorrect for me, i.e. SCALE infos):
Code: Select all
mBeyondFarDistance = false;
if (cam->getUseRenderingDistance() && mUpperDistance > 0)
{
//Real rad = getBoundingRadius();
Real squaredDepth = mParentNode->getSquaredViewDepth(cam->getLodCamera());
//const Vector3& scl = mParentNode->_getDerivedScale();
//Real factor = std::max(std::max(scl.x, scl.y), scl.z);
// Max distance to still render
Real maxDist = mUpperDistance;// + rad * factor;
if (squaredDepth > Math::Sqr(maxDist))
{
mBeyondFarDistance = true;
}
}
The renderingDistance check in Ogre should really be plain and simple, the Application should care about the Scale...
that's what I think, and I'll support my theory with a practical case that occurred to me, if you have the patience to read until the conclusions.
---------------------------------------------------------------------------------------------------------
PRACTICAL CASE STUDY
I've recently completed a 3D Label (about which you can read in this post), so only a quick recap: it consist of 2 MovableObjects (Entities) that encapsulates Meshes, one for the Text of the Label (textEntity) and one for the background panel (panelEntity).
With textEntity everything is fine because it ISN'T SCALED, but with panelEntity there are problems because it's a 1x1 unit quad (2 triangles) mesh created only once and then instantiated in each panelEntity of each 3D Label; it is then scaled (through its SceneNode) accordingly to match 3D Label's panel dimensions.
Here follows a couple of debug messages I've printed from my application when they disappear (further away from the wanted renderingDistance), and also a when they become visible (rendered) again.
Code: Select all
'3DLabel#1' is now BEYOND far distance! {if (squaredDepth > Math.Pow(maxDist,2)}
[RenderingDistance: 1500,0| depth: 1812,36| radius: 35,4| factor: 50,0| maxDist: 1767,8| squaredDepth: 3284652,0| squaredMaxDist: 3125000,1]
'3DLabel#2' is now BEYOND far distance! {if (squaredDepth > Math.Pow(maxDist,2)}
[RenderingDistance: 1500,0| depth: 3976,51| radius: 52,8| factor: 74,7| maxDist: 3944,4| squaredDepth: 15812660,0| squaredMaxDist: 15558284,8]
'3DLabel#2' is now NEARER than far distance!
[RenderingDistance: 1500,0| depth: 3851,73| radius: 52,8| factor: 74,7| maxDist: 3944,4| squaredDepth: 14835850,0| squaredMaxDist: 15558284,8]
'3DLabel#1' is now NEARER than far distance!
[RenderingDistance: 1500,0| depth: 1689,53| radius: 35,4| factor: 50,0| maxDist: 1767,8| squaredDepth: 2854517,0| squaredMaxDist: 3125000,1]
As you can note, the desired RenderingDistance is 1500 (is it a bit small? Maybe, it depends on may aspects, but if I want that I should get it - as I do for textEntity that isn't scaled); now, the point is that (for "3DLabel#1") with a radius of 35 and a (scale) factor of 50 (the width of the 3D Label, thus the x scale of the panelEntity), their multiplication give us 1750.
But if I want the test to pass at 1500 World units, I should initially assign the RenderingDistance to 1500 (desired distance) - 1750 (radius * factor) = -250; the problem is that if I assign a NEGATIVE value to the RenderingDistance, it has the same effect to assign NOTHING and keep it zero (default value); as you can see from the Ogre code (you can find it at the beginning of MovableObject::_notifyCurrentCamera(Camera* cam)), it will be taken into account only if the mUpperDistance (assigned when you call setRenderingDistance()) is greater than zero!
|!| In this (my) case it's IMPOSSIBLE to assign to my panelEntity a RenderingDistance value that will cut it at 1500 units from the Camera, because of the current code of Ogre.
That's why I'm stating that Ogre shouldn't take the MovableObject's SCALE into account when checking for the maxDistance.
---------------------------------------------------------------------------------------------------------
If this isn't the right place, where should I state my point, I mean in what Forum, what Topic?
If you have understood, do you share my point of view about this argument?
|_ If yes, what's the procedure to prepare/propose a patch to the dev team?
|_ If not, can you explain to me why it's important to take the MovableObject's scale into account? And in that case, how can I possibly set my desired renderingDistance in my panelEntity?
Thanks a lot in advance to anyone for you reply!
