From: ehofman Date: Mon, 18 Jul 2005 16:57:20 +0000 (+0000) Subject: Harald JOHSEN: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f93ea20d5ec64c2024b2f3c05697a6cb137ef71d;p=simgear.git Harald JOHSEN: Changes ======= - shadowvolume.cxx, renderer.cxx : - reduced the polygon offset a bit to eliminate some artifact ; - changed again the cleanup code for objects inside a tile because it could crash on rare occasion ; - the culling of shadow casters has been rewritten to traverse the scene graph, it should be a bit faster when there is a lot of objects ; - the range selector was not correctly handled, sometimes the wrong LOD was casting shadows. - added the option to display aircraft's transparent objects after the shadows, this will reduce the problem of shadows being hidden by the transparent object (propeller disk, rotor, etc). A side effect is that aircraft's transparent objects won't receive shadows anymore. This is usually a good thing except when the aircraft use a 'transparent' texture where it should not. A transparent texture in the plib context is a texture with an alpha channel or a material with alpha <= 0.99. - model.cxx, animation.cxx, shadowvolume.cxx : - added an optional under the animation - tower.cxx - correct a rare bug where all occurences of the aircraft are not deleted from the departure list causing a crash in FGTower::CheckDepartureList function. --- diff --git a/simgear/scene/model/animation.cxx b/simgear/scene/model/animation.cxx index 1307987e..67ee8dd7 100644 --- a/simgear/scene/model/animation.cxx +++ b/simgear/scene/model/animation.cxx @@ -1506,15 +1506,35 @@ void SGDistScaleAnimation::distScaleCallback( sgMat4 r, sgFrustum *f, sgMat4 m ) // Implementation of SGShadowAnimation //////////////////////////////////////////////////////////////////////// -SGShadowAnimation::SGShadowAnimation (SGPropertyNode_ptr props) - : SGAnimation(props, new ssgBranch) +SGShadowAnimation::SGShadowAnimation ( SGPropertyNode *prop_root, + SGPropertyNode_ptr props ) + : SGAnimation(props, new ssgBranch), + _condition(0), + _condition_value(true) { animation_type = 1; + SGPropertyNode_ptr node = props->getChild("condition"); + if (node != 0) { + _condition = sgReadCondition(prop_root, node); + _condition_value = false; + } } SGShadowAnimation::~SGShadowAnimation () { + delete _condition; +} + +int +SGShadowAnimation::update() +{ + if (_condition) + _condition_value = _condition->test(); + return 2; } +bool SGShadowAnimation::get_condition_value(void) { + return _condition_value; +} // end of animation.cxx diff --git a/simgear/scene/model/animation.hxx b/simgear/scene/model/animation.hxx index f6f5fa45..535cb276 100644 --- a/simgear/scene/model/animation.hxx +++ b/simgear/scene/model/animation.hxx @@ -589,8 +589,14 @@ private: class SGShadowAnimation : public SGAnimation { public: - SGShadowAnimation (SGPropertyNode_ptr props); + SGShadowAnimation ( SGPropertyNode *prop_root, + SGPropertyNode_ptr props ); virtual ~SGShadowAnimation (); + virtual int update(); + bool get_condition_value(void); +private: + SGCondition * _condition; + bool _condition_value; }; diff --git a/simgear/scene/model/model.cxx b/simgear/scene/model/model.cxx index 2a27815b..cae2718c 100644 --- a/simgear/scene/model/model.cxx +++ b/simgear/scene/model/model.cxx @@ -166,7 +166,7 @@ sgMakeAnimation( ssgBranch * model, } else if (!strcmp("dist-scale", type)) { animation = new SGDistScaleAnimation(node); } else if (!strcmp("noshadow", type)) { - animation = new SGShadowAnimation(node); + animation = new SGShadowAnimation(prop_root, node); } else { animation = new SGNullAnimation(node); SG_LOG(SG_INPUT, SG_WARN, "Unknown animation type " << type); diff --git a/simgear/scene/model/shadowvolume.cxx b/simgear/scene/model/shadowvolume.cxx index 88f065f6..9e0a1294 100644 --- a/simgear/scene/model/shadowvolume.cxx +++ b/simgear/scene/model/shadowvolume.cxx @@ -27,6 +27,7 @@ #include #include #include +#include #include SG_GLU_H #include "shadowvolume.hxx" @@ -116,10 +117,15 @@ SGShadowVolume::ShadowCaster::ShadowCaster( int _num_tri, ssgBranch * _geometry_ ssgBranch *branch = (ssgBranch *) _geometry_leaf; while( branch && branch->getNumParents() > 0 ) { - if( !first_select && branch->isA(ssgTypeSelector())) { + if( branch->isAKindOf(ssgTypeSelector())) { first_select = branch; break; } + if( sgCheckAnimationBranch( (ssgEntity *) branch ) ) + if( ((SGAnimation *) branch->getUserData())->get_animation_type() == 1) { + first_select = branch; + break; + } branch = branch->getParent(0); } } @@ -150,6 +156,7 @@ void SGShadowVolume::ShadowCaster::addLeaf( int & tri_idx, int & ind_idx, ssgLea } if( num_tri == 0 ) return; + isTranslucent |= geometry_leaf->isTranslucent() ? true : false; int num_ind = geometry_leaf->getNumVertices(); ind_idx += num_ind; } @@ -302,7 +309,7 @@ void SGShadowVolume::ShadowCaster::DrawInfiniteShadowVolume(sgVec3 lightPosition glDrawElements ( GL_TRIANGLES, lastSilhouetteIndicesCount, GL_UNSIGNED_SHORT, silhouetteEdgeIndices ) ; //Draw caps if required - if(drawCaps) + if(drawCaps) { glBegin(GL_TRIANGLES); { @@ -344,8 +351,19 @@ void SGShadowVolume::ShadowCaster::getNetTransform ( ssgBranch * branch, sgMat4 // check the value of