Changeset 657 for OGRE/trunk/ogre_changes
- Timestamp:
- 02/20/06 19:06:03 (19 years ago)
- Location:
- OGRE/trunk/ogre_changes
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
OGRE/trunk/ogre_changes/OgreMain/include/OgreFrustum.h
r61 r657 445 445 /** Disables any custom near clip plane. */ 446 446 virtual void disableCustomNearClipPlane(void); 447 /** Is a custom near clip plane in use? */ 448 virtual bool isCustomNearClipPlaneEnabled(void) const 449 { return mObliqueDepthProjection; } 447 450 448 451 -
OGRE/trunk/ogre_changes/OgreMain/include/OgreHardwareOcclusionQuery.h
r115 r657 46 46 * 47 47 * @author Lee Sandberg 48 * Updated on 4/8/2005 by Tuan Kuranes email: tuan.kuranes@free.fr 48 49 */ 49 50 class _OgreExport HardwareOcclusionQuery … … 82 83 * UINT m_uintNumberOfPixelsVisable; 83 84 * pullOcclusionQuery( &m_dwNumberOfPixelsVisable ); 84 * You may not get the result directl ly after the first pass or frame.85 * Objects not vis able must be tested every frame, visable objects may be tested less freqvent.85 * You may not get the result directly after the first pass or frame. 86 * Objects not visible must be tested every frame, visible objects may be tested less frequently. 86 87 * 87 88 */ … … 112 113 * 113 114 * @Remarks This function allows you to set how often the hardware occlusion really are sent to the driver 114 * if you set it to 0 every h w occlusion test is acctually made. If you set it to 1 only the half of your queries are sent115 * for all vis able objects. 2 will result in 25% of all queries to acctualy be sent.116 * New and none vis able objects will be tested all the time.117 * This functionality is here because this class can keep track on vis able and none visable objects for you.115 * if you set it to 0 every hardware occlusion test is actually made. If you set it to 1 only the half of your queries are sent 116 * for all visible objects. 2 will result in 25% of all queries to actually be sent. 117 * New and none visible objects will be tested all the time. 118 * This functionality is here because this class can keep track on visible and none visible objects for you. 118 119 * Once you you set the SkipRate for any hardware occlusion instance it effects all others. 119 120 */ -
OGRE/trunk/ogre_changes/OgreMain/include/OgreRenderQueueSortingGrouping.h
r343 r657 316 316 } 317 317 318 319 @ remarks320 Doesn't delete any priority groups, just empties them. Saves on318 /** Clears this group of renderables. 319 @param destroy 320 If false, doesn't delete any priority groups, just empties them. Saves on 321 321 memory deallocations since the chances are rougly the same kinds of 322 renderables are going to be sent to the queue again next time. 323 */ 324 void clear(void) 322 renderables are going to be sent to the queue again next time. If 323 true, completely destroys. 324 */ 325 void clear(bool destroy = false) 325 326 { 326 327 PriorityMap::iterator i, iend; … … 328 329 for (i = mPriorityGroups.begin(); i != iend; ++i) 329 330 { 330 i->second->clear(); 331 } 332 333 } 331 if (destroy) 332 delete i->second; 333 else 334 i->second->clear(); 335 } 336 337 if (destroy) 338 mPriorityGroups.clear(); 339 340 } 341 334 342 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 335 343 void clear(int passes) -
OGRE/trunk/ogre_changes/OgreMain/include/OgreRenderSystem.h
r316 r657 42 42 #include "OgreGpuProgram.h" 43 43 #include "OgrePlane.h" 44 #include "OgreIteratorWrappers.h" 44 45 45 46 namespace Ogre … … 173 174 virtual void setConfigOption(const String &name, const String &value) = 0; 174 175 175 virtual HardwareOcclusionQuery* createHardwareOcclusionQuery() = 0; 176 /** Create an object for performing hardware occlusion queries. 177 */ 178 virtual HardwareOcclusionQuery* createHardwareOcclusionQuery(void) = 0; 179 180 /** Destroy a hardware occlusion query object. 181 */ 182 virtual void destroyHardwareOcclusionQuery(HardwareOcclusionQuery *hq); 176 183 177 184 /** Validates the options set for the rendering system, returning a message if there are problems. … … 295 302 Description: External window handle, for embedding the OGRE context 296 303 Values: positive integer for W32 (HWND handle) 297 posint:posint:posint for GLX (display:screen:windowHandle) 304 poslong:posint:poslong (display*:screen:windowHandle) or 305 poslong:posint:poslong:poslong (display*:screen:windowHandle:XVisualInfo*) for GLX 298 306 Default: 0 (None) 299 307 ** … … 301 309 Description: Parent window handle, for embedding the OGRE context 302 310 Values: positive integer for W32 (HWND handle) 303 pos int:posint:posint for GLX (display:screen:windowHandle)311 poslong:posint:poslong for GLX (display*:screen:windowHandle) 304 312 Default: 0 (None) 305 313 ** … … 392 400 virtual RenderTarget * detachRenderTarget( const String &name ); 393 401 402 /// Iterator over RenderTargets 403 typedef MapIterator<Ogre::RenderTargetMap> RenderTargetIterator; 404 405 /** Returns a specialised MapIterator over all render targets attached to the RenderSystem. */ 406 virtual RenderTargetIterator getRenderTargetIterator(void) { 407 return RenderTargetIterator( mRenderTargets.begin(), mRenderTargets.end() ); 408 } 394 409 /** Returns a description of an error code. 395 410 */ … … 947 962 virtual Real getMaximumDepthInputValue(void) = 0; 948 963 964 /** Defines a listener on the custom events that this render system 965 can raise. 966 @see RenderSystem::addListener 967 */ 968 class _OgreExport Listener 969 { 970 public: 971 Listener() {} 972 virtual ~Listener() {} 973 974 /** A rendersystem-specific event occurred. 975 @param eventName The name of the event which has occurred 976 @param parameters A list of parameters that may belong to this event, 977 may be null if there are no parameters 978 */ 979 virtual void eventOccurred(const String& eventName, 980 const NameValuePairList* parameters = 0) = 0; 981 }; 982 /** Adds a listener to the custom events that this render system can raise. 983 @remarks 984 Some render systems have quite specific, internally generated events 985 that the application may wish to be notified of. Many applications 986 don't have to worry about these events, and can just trust OGRE to 987 handle them, but if you want to know, you can add a listener here. 988 @par 989 Events are raised very generically by string name. Perhaps the most 990 common example of a render system specific event is the loss and 991 restoration of a device in DirectX; which OGRE deals with, but you 992 may wish to know when it happens. 993 @see RenderSystem::getRenderSystemEvents 994 */ 995 virtual void addListener(Listener* l); 996 /** Remove a listener to the custom events that this render system can raise. 997 */ 998 virtual void removeListener(Listener* l); 999 1000 /** Gets a list of the rendersystem specific events that this rendersystem 1001 can raise. 1002 @see RenderSystem::addListener 1003 */ 1004 virtual const StringVector& getRenderSystemEvents(void) const { return mEventNames; } 949 1005 protected: 950 1006 … … 984 1040 985 1041 bool mInvertVertexWinding; 1042 1043 /// List of names of events this rendersystem may raise 1044 StringVector mEventNames; 1045 1046 /// Internal method for firing a rendersystem event 1047 virtual void fireEvent(const String& name, const NameValuePairList* params = 0); 1048 1049 typedef std::list<Listener*> ListenerList; 1050 ListenerList mEventListeners; 1051 1052 typedef std::list<HardwareOcclusionQuery*> HardwareOcclusionQueryList; 1053 HardwareOcclusionQueryList mHwOcclusionQueries; 1054 1055 986 1056 }; 987 1057 } -
OGRE/trunk/ogre_changes/OgreMain/include/OgreSceneManager.h
r316 r657 271 271 */ 272 272 virtual void initRenderQueue(void); 273 /** Retrieves the internal render queue. */274 virtual RenderQueue* getRenderQueue(void);275 276 273 /** Internal method for setting up the renderstate for a rendering pass. 277 274 @param … … 282 279 */ 283 280 virtual Pass* setPass(Pass* pass); 284 285 281 /// A pass designed to let us render shadow colour on white for texture shadows 286 282 Pass* mShadowCasterPlainBlackPass; … … 429 425 virtual void createShadowTextures(unsigned short size, unsigned short count, 430 426 PixelFormat fmt); 427 /// Internal method for destroying shadow textures (texture-based shadows) 428 virtual void destroyShadowTextures(void); 431 429 /// Internal method for preparing shadow textures ready for use in a regular render 432 430 virtual void prepareShadowTextures(Camera* cam, Viewport* vp); … … 582 580 583 581 /** Removes (and destroys) all cameras from the scene. 582 @remarks 583 Some cameras are internal created to dealing with texture shadow, 584 their aren't supposed to destroy outside. So, while you are using 585 texture shadow, don't call this method, or you can set the shadow 586 technique other than texture-based, which will destroy all internal 587 created shadow cameras and textures. 584 588 */ 585 589 virtual void removeAllCameras(void); … … 1025 1029 const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 1026 1030 1031 /** Return whether a key plane is enabled */ 1032 virtual bool isSkyPlaneEnabled(void) const { return mSkyPlaneEnabled; } 1033 1034 /** Get the sky plane node, if enabled. */ 1035 virtual SceneNode* getSkyPlaneNode(void) { return mSkyPlaneNode; } 1036 1027 1037 /** Enables / disables a 'sky box' i.e. a 6-sided box at constant 1028 1038 distance from the camera representing the sky. … … 1070 1080 bool drawFirst = true, const Quaternion& orientation = Quaternion::IDENTITY, 1071 1081 const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 1082 1083 /** Return whether a skybox is enabled */ 1084 virtual bool isSkyBoxEnabled(void) const { return mSkyBoxEnabled; } 1085 1086 /** Get the skybox node, if enabled. */ 1087 virtual SceneNode* getSkyBoxNode(void) const { return mSkyBoxNode; } 1072 1088 1073 1089 /** Enables / disables a 'sky dome' i.e. an illusion of a curved sky. … … 1132 1148 int xsegments = 16, int ysegments = 16, int ysegments_keep = -1, 1133 1149 const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 1150 1151 /** Return whether a skydome is enabled */ 1152 virtual bool isSkyDomeEnabled(void) const { return mSkyDomeEnabled; } 1153 1154 /** Get the sky dome node, if enabled. */ 1155 virtual SceneNode* getSkyDomeNode(void) { return mSkyDomeNode; } 1134 1156 1135 1157 /** Sets the fogging mode applied to the scene. … … 1340 1362 const Matrix4& worldMatrix, const Matrix4& viewMatrix, const Matrix4& projMatrix, 1341 1363 bool doBeginEndFrame = false) ; 1364 1365 /** Retrieves the internal render queue, for advanced users only. 1366 @remarks 1367 The render queue is mainly used internally to manage the scene object 1368 rendering queue, it also exports some methods to allow advanced users 1369 to configure the behavior of rendering process. 1370 Most methods provided by RenderQueue are supposed to be used 1371 internally only, you should reference to the RenderQueue API for 1372 more information. Do not access this directly unless you know what 1373 you are doing. 1374 */ 1375 virtual RenderQueue* getRenderQueue(void); 1342 1376 1343 1377 /** Registers a new RenderQueueListener which will be notified when render queues -
OGRE/trunk/ogre_changes/OgreMain/src/OgreRenderSystem.cpp
r316 r657 40 40 #include "OgreMaterial.h" 41 41 #include "OgreTimer.h" 42 #include "OgreHardwareOcclusionQuery.h" 42 43 43 44 namespace Ogre { … … 69 70 { 70 71 shutdown(); 72 delete mCapabilities; 73 mCapabilities = 0; 71 74 } 72 75 //----------------------------------------------------------------------- … … 324 327 void RenderSystem::shutdown(void) 325 328 { 329 // Remove occlusion queries 330 for (HardwareOcclusionQueryList::iterator i = mHwOcclusionQueries.begin(); 331 i != mHwOcclusionQueries.end(); ++i) 332 { 333 delete *i; 334 } 335 mHwOcclusionQueries.clear(); 336 326 337 // Remove all the render targets. 327 338 // (destroy primary target last since others may depend on it) … … 416 427 } 417 428 } 429 //----------------------------------------------------------------------- 430 void RenderSystem::addListener(Listener* l) 431 { 432 mEventListeners.push_back(l); 433 } 434 //----------------------------------------------------------------------- 435 void RenderSystem::removeListener(Listener* l) 436 { 437 mEventListeners.remove(l); 438 } 439 //----------------------------------------------------------------------- 440 void RenderSystem::fireEvent(const String& name, const NameValuePairList* params) 441 { 442 for(ListenerList::iterator i = mEventListeners.begin(); 443 i != mEventListeners.end(); ++i) 444 { 445 (*i)->eventOccurred(name, params); 446 } 447 } 448 //----------------------------------------------------------------------- 449 void RenderSystem::destroyHardwareOcclusionQuery( HardwareOcclusionQuery *hq) 450 { 451 for (HardwareOcclusionQueryList::iterator i = mHwOcclusionQueries.begin(); 452 i != mHwOcclusionQueries.end(); ++i) 453 { 454 if (*i == hq) 455 { 456 delete *i; 457 mHwOcclusionQueries.erase(i); 458 break; 459 } 460 } 461 } 462 418 463 } 419 464 -
OGRE/trunk/ogre_changes/OgreMain/src/OgreSceneManager.cpp
r343 r657 375 375 // Subclasses could do something smarter 376 376 destList.clear(); 377 Real squaredRadius = radius * radius;378 377 379 378 SceneLightList::iterator i, iend; … … 396 395 // only add in-range lights 397 396 Real range = lt->getAttenuationRange(); 398 if ((lt->tempSquareDist - squaredRadius) <= (range * range)) 397 Real maxDist = range + radius; 398 if (lt->tempSquareDist <= Math::Sqr(maxDist)) 399 399 { 400 400 destList.push_back(lt); … … 554 554 mSkyBoxEnabled = mSkyPlaneEnabled = mSkyDomeEnabled = false; 555 555 556 // Clear render queue, empty completely 557 if (mRenderQueue) 558 mRenderQueue->clear(true); 559 556 560 } 557 561 //----------------------------------------------------------------------- … … 593 597 AutoTrackingSceneNodes::iterator ai, aiend; 594 598 aiend = mAutoTrackingSceneNodes.end(); 595 for (ai = mAutoTrackingSceneNodes.begin(); ai != aiend; ++ai) 596 { 597 SceneNode* n = *ai; 599 for (ai = mAutoTrackingSceneNodes.begin(); ai != aiend; ) 600 { 601 // Pre-increment incase we delete 602 AutoTrackingSceneNodes::iterator curri = ai++; 603 SceneNode* n = *curri; 598 604 // Tracking this node 599 605 if (n->getAutoTrackTarget() == i->second) … … 601 607 // turn off, this will notify SceneManager to remove 602 608 n->setAutoTracking(false); 603 // no need to reset iterator since set erase does not invalidate604 609 } 605 610 // node is itself a tracker 606 611 else if (n == i->second) 607 612 { 608 mAutoTrackingSceneNodes.erase( ai);613 mAutoTrackingSceneNodes.erase(curri); 609 614 } 610 615 } … … 814 819 if (thisFrameNumber != lastFrameNumber) 815 820 { 821 // Update controllers 822 ControllerManager::getSingleton().updateAllControllers(); 816 823 // Update animations 817 824 _applySceneAnimations(); 818 // Update controllers819 ControllerManager::getSingleton().updateAllControllers();820 825 lastFrameNumber = thisFrameNumber; 821 826 } … … 868 873 } 869 874 875 // Tell params about viewport 876 mAutoParamDataSource.setCurrentViewport(vp); 870 877 // Set the viewport 871 878 setViewport(vp); … … 1409 1416 { 1410 1417 // Someone requested we skip this queue 1411 continue;1418 break; 1412 1419 } 1413 1420 … … 1713 1720 mShadowReceiverPass->_load(); 1714 1721 1715 if (l->getCastShadows() && pGroup->getShadowsEnabled())1722 if (l->getCastShadows()) 1716 1723 { 1717 1724 renderTextureShadowReceiverQueueGroupObjects(pGroup); … … 1876 1883 { 1877 1884 // Ordinary pass 1885 if (pGroup->getShadowsEnabled()) 1878 1886 renderModulativeTextureShadowedQueueGroupObjects(pGroup); 1887 else 1888 renderBasicQueueGroupObjects(pGroup); 1879 1889 } 1880 1890 } … … 2118 2128 { 2119 2129 mAmbientLight = colour; 2120 mDestRenderSystem->setAmbientLight(colour.r, colour.g, colour.b);2121 2130 } 2122 2131 //----------------------------------------------------------------------- … … 2656 2665 { 2657 2666 createShadowTextures(mShadowTextureSize, mShadowTextureCount, mShadowTextureFormat); 2667 } 2668 else 2669 { 2670 // Destroy shadow textures to optimise resource usage 2671 destroyShadowTextures(); 2658 2672 } 2659 2673 … … 2764 2778 const Vector3* corners = camera->getWorldSpaceCorners(); 2765 2779 Vector3 min, max; 2766 Vector3 extrude = light->getD irection() * -mShadowDirLightExtrudeDist;2780 Vector3 extrude = light->getDerivedDirection() * -mShadowDirLightExtrudeDist; 2767 2781 // do first corner 2768 2782 min = max = corners[0]; … … 2792 2806 else 2793 2807 { 2794 Sphere s(light->get Position(), light->getAttenuationRange());2808 Sphere s(light->getDerivedPosition(), light->getAttenuationRange()); 2795 2809 // eliminate early if camera cannot see light sphere 2796 2810 if (camera->isVisible(s)) … … 2875 2889 { 2876 2890 mShadowDebugPass = matDebug->getTechnique(0)->getPass(0); 2891 2892 if (mDestRenderSystem->getCapabilities()->hasCapability(RSC_VERTEX_PROGRAM)) 2893 { 2894 mInfiniteExtrusionParams = mShadowDebugPass->getVertexProgramParameters(); 2895 } 2877 2896 } 2878 2897 } … … 2915 2934 { 2916 2935 mShadowStencilPass = matStencil->getTechnique(0)->getPass(0); 2936 2937 if (mDestRenderSystem->getCapabilities()->hasCapability(RSC_VERTEX_PROGRAM)) 2938 { 2939 mFiniteExtrusionParams = mShadowStencilPass->getVertexProgramParameters(); 2940 } 2917 2941 } 2918 2942 } … … 3029 3053 Pass* SceneManager::deriveShadowCasterPass(Pass* pass) 3030 3054 { 3055 Pass* retPass = 0; 3031 3056 switch (mShadowTechnique) 3032 3057 { 3033 3058 case SHADOWTYPE_TEXTURE_MODULATIVE: 3034 if (mShadowTextureCustomCasterPass) 3059 retPass = mShadowTextureCustomCasterPass ? 3060 mShadowTextureCustomCasterPass : mShadowCasterPlainBlackPass; 3061 3062 3063 // Special case alpha-blended passes 3064 if ((pass->getSourceBlendFactor() == SBF_SOURCE_ALPHA && 3065 pass->getDestBlendFactor() == SBF_ONE_MINUS_SOURCE_ALPHA) 3066 || pass->getAlphaRejectFunction() != CMPF_ALWAYS_PASS) 3035 3067 { 3036 // Caster pass has been customised 3068 // Alpha blended passes must retain their transparency 3069 retPass->setAlphaRejectSettings(pass->getAlphaRejectFunction(), 3070 pass->getAlphaRejectValue()); 3071 retPass->setSceneBlending(pass->getSourceBlendFactor(), pass->getDestBlendFactor()); 3072 retPass->getParent()->getParent()->setTransparencyCastsShadows(true); 3073 3074 // So we allow the texture units, but override the colour functions 3075 // Copy texture state, shift up one since 0 is shadow texture 3076 size_t origPassTUCount = pass->getNumTextureUnitStates(); 3077 for (size_t t = 0; t < origPassTUCount; ++t) 3078 { 3079 TextureUnitState* tex; 3080 if (retPass->getNumTextureUnitStates() <= t) 3081 { 3082 tex = retPass->createTextureUnitState(); 3083 } 3084 else 3085 { 3086 tex = retPass->getTextureUnitState(t); 3087 } 3088 // copy base state 3089 (*tex) = *(pass->getTextureUnitState(t)); 3090 // override colour function 3091 tex->setColourOperationEx(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, 3092 mShadowColour); 3093 3094 } 3095 // Remove any extras 3096 while (retPass->getNumTextureUnitStates() > origPassTUCount) 3097 { 3098 retPass->removeTextureUnitState(origPassTUCount); 3099 } 3100 3101 } 3102 else 3103 { 3104 // reset 3105 retPass->setSceneBlending(SBF_ONE, SBF_ZERO); 3106 retPass->setAlphaRejectFunction(CMPF_ALWAYS_PASS); 3107 while (retPass->getNumTextureUnitStates() > 0) 3108 { 3109 retPass->removeTextureUnitState(0); 3110 } 3111 } 3112 3113 // Propagate culling modes 3114 retPass->setCullingMode(pass->getCullingMode()); 3115 retPass->setManualCullingMode(pass->getManualCullingMode()); 3116 3037 3117 3038 3118 if (!pass->getShadowCasterVertexProgramName().empty()) 3039 3119 { 3040 3120 // Have to merge the shadow caster vertex program in 3041 mShadowTextureCustomCasterPass->setVertexProgram(3121 retPass->setVertexProgram( 3042 3122 pass->getShadowCasterVertexProgramName()); 3043 const GpuProgramPtr& prg = mShadowTextureCustomCasterPass->getVertexProgram();3123 const GpuProgramPtr& prg = retPass->getVertexProgram(); 3044 3124 // Load this program if not done already 3045 3125 if (!prg->isLoaded()) 3046 3126 prg->load(); 3047 3127 // Copy params 3048 mShadowTextureCustomCasterPass->setVertexProgramParameters(3128 retPass->setVertexProgramParameters( 3049 3129 pass->getShadowCasterVertexProgramParameters()); 3130 if (retPass == mShadowTextureCustomCasterPass) 3131 { 3050 3132 // mark that we've overridden the standard 3051 3133 mShadowTextureCasterVPDirty = true; 3134 } 3052 3135 // Also have to hack the light autoparams, that is done later 3053 3136 } 3054 else if (mShadowTextureCasterVPDirty) 3137 else 3138 { 3139 retPass->setVertexProgram(StringUtil::BLANK); 3140 if (mShadowTextureCasterVPDirty) 3055 3141 { 3056 3142 // reset … … 3065 3151 mShadowTextureCasterVPDirty = false; 3066 3152 } 3067 return mShadowTextureCustomCasterPass;3068 3153 } 3069 else 3070 { 3071 // Standard pass 3072 if (pass->hasVertexProgram()) 3073 { 3074 // Have to merge the shadow caster vertex program in 3075 // This may in fact be blank, in which case it falls back on 3076 // fixed function 3077 mShadowCasterPlainBlackPass->setVertexProgram( 3078 pass->getShadowCasterVertexProgramName()); 3079 // Did this result in a new vertex program? 3080 if (mShadowCasterPlainBlackPass->hasVertexProgram()) 3081 { 3082 const GpuProgramPtr& prg = mShadowCasterPlainBlackPass->getVertexProgram(); 3083 // Load this program if not done already 3084 if (!prg->isLoaded()) 3085 prg->load(); 3086 // Copy params 3087 mShadowCasterPlainBlackPass->setVertexProgramParameters( 3088 pass->getShadowCasterVertexProgramParameters()); 3089 } 3090 // Also have to hack the light autoparams, that is done later 3091 } 3092 else if (mShadowCasterPlainBlackPass->hasVertexProgram()) 3093 { 3094 // reset 3095 mShadowCasterPlainBlackPass->setVertexProgram(""); 3096 } 3097 return mShadowCasterPlainBlackPass; 3098 } 3154 return retPass; 3099 3155 default: 3100 3156 return pass; … … 3301 3357 { 3302 3358 ShadowCaster* caster = *si; 3303 bool zfailAlgo = false;3359 bool zfailAlgo = camera->isCustomNearClipPlaneEnabled(); 3304 3360 unsigned long flags = 0; 3305 3361 … … 3705 3761 3706 3762 // destroy existing 3707 ShadowTextureList::iterator i, iend; 3708 iend = mShadowTextures.end(); 3709 for (i = mShadowTextures.begin(); i != iend; ++i) 3710 { 3711 RenderTexture* r = *i; 3712 // remove camera and destroy texture 3713 removeCamera(r->getViewport(0)->getCamera()); 3714 mDestRenderSystem->destroyRenderTexture(r->getName()); 3715 } 3716 mShadowTextures.clear(); 3763 destroyShadowTextures(); 3717 3764 3718 3765 // Recreate shadow textures … … 3762 3809 3763 3810 } 3811 } 3812 //--------------------------------------------------------------------- 3813 void SceneManager::destroyShadowTextures(void) 3814 { 3815 ShadowTextureList::iterator i, iend; 3816 iend = mShadowTextures.end(); 3817 for (i = mShadowTextures.begin(); i != iend; ++i) 3818 { 3819 RenderTexture* r = *i; 3820 // remove camera and destroy texture 3821 removeCamera(r->getViewport(0)->getCamera()); 3822 mDestRenderSystem->destroyRenderTexture(r->getName()); 3823 } 3824 mShadowTextures.clear(); 3764 3825 } 3765 3826 //--------------------------------------------------------------------- -
OGRE/trunk/ogre_changes/OgreMain/src/OgreSceneNode.cpp
r158 r657 296 296 { 297 297 SceneNode* sceneChild = static_cast<SceneNode*>(child->second); 298 sceneChild->_findVisibleObjects(cam, queue, includeChildren, displayNodes); 298 sceneChild->_findVisibleObjects(cam, queue, includeChildren, 299 displayNodes, onlyShadowCasters); 299 300 } 300 301 } … … 391 392 ChildNodeMap::iterator i, iend; 392 393 iend = mChildren.end(); 393 for (i = mChildren.begin(); i != iend; ++i)394 for (i = mChildren.begin(); i != iend;) 394 395 { 395 396 SceneNode* sn = static_cast<SceneNode*>(i->second); 397 // increment iterator before destroying (iterator invalidated by 398 // SceneManager::destroySceneNode because it causes removal from parent) 399 ++i; 396 400 sn->removeAndDestroyAllChildren(); 397 401 sn->getCreator()->destroySceneNode(sn->getName()); … … 482 486 if (vec == Vector3::ZERO) return; 483 487 484 // Adjust vector so that it is relative to local Z 485 Vector3 zAdjustVec; 486 if (localDirectionVector == Vector3::NEGATIVE_UNIT_Z) 487 { 488 zAdjustVec = -vec; 489 } 490 else 491 { 492 Quaternion localToUnitZ = localDirectionVector.getRotationTo(Vector3::UNIT_Z); 493 zAdjustVec = localToUnitZ * vec; 494 } 495 zAdjustVec.normalise(); 496 488 // The direction we want the local direction point to 489 Vector3 targetDir = vec.normalisedCopy(); 490 491 // Transform target direction to world space 492 switch (relativeTo) 493 { 494 case TS_PARENT: 495 if (mParent) 496 targetDir = mParent->_getDerivedOrientation() * targetDir; 497 break; 498 case TS_LOCAL: 499 targetDir = _getDerivedOrientation() * targetDir; 500 break; 501 } 502 503 // Calculate target orientation relative to world space 497 504 Quaternion targetOrientation; 498 505 if( mYawFixed ) 499 506 { 500 Vector3 xVec = mYawFixedAxis.crossProduct( zAdjustVec ); 507 // Calculate the quaternion for rotate local Z to target direction 508 Vector3 xVec = mYawFixedAxis.crossProduct(targetDir); 501 509 xVec.normalise(); 502 503 Vector3 yVec = zAdjustVec.crossProduct( xVec ); 510 Vector3 yVec = targetDir.crossProduct(xVec); 504 511 yVec.normalise(); 512 Quaternion unitZToTarget = Quaternion(xVec, yVec, targetDir); 505 513 506 targetOrientation.FromAxes( xVec, yVec, zAdjustVec ); 514 if (localDirectionVector == Vector3::NEGATIVE_UNIT_Z) 515 { 516 // Specail case for avoid calculate 180 degree turn 517 targetOrientation = 518 Quaternion(-unitZToTarget.y, -unitZToTarget.z, unitZToTarget.w, unitZToTarget.x); 507 519 } 508 520 else 509 521 { 510 511 // Get axes from current quaternion512 Vector3 axes[3];513 _getDerivedOrientation().ToAxes(axes);514 Quaternion rotQuat;515 if ( (axes[2]+zAdjustVec).squaredLength() < 0.00005f)522 // Calculate the quaternion for rotate local direction to target direction 523 Quaternion localToUnitZ = localDirectionVector.getRotationTo(Vector3::UNIT_Z); 524 targetOrientation = unitZToTarget * localToUnitZ; 525 } 526 } 527 else 516 528 { 529 const Quaternion& currentOrient = _getDerivedOrientation(); 530 531 // Get current local direction relative to world space 532 Vector3 currentDir = currentOrient * localDirectionVector; 533 534 if ((currentDir+targetDir).squaredLength() < 0.00005f) 535 { 517 536 // Oops, a 180 degree turn (infinite possible rotation axes) 518 537 // Default to yaw i.e. use current UP 519 rotQuat.FromAngleAxis(Radian(Math::PI), axes[1]); 520 } 521 else 522 { 538 targetOrientation = 539 Quaternion(-currentOrient.y, -currentOrient.z, currentOrient.w, currentOrient.x); 540 } 541 else 542 { 523 543 // Derive shortest arc to new direction 524 rotQuat = axes[2].getRotationTo(zAdjustVec); 525 526 } 527 targetOrientation = rotQuat * mOrientation; 528 } 529 530 if (relativeTo == TS_LOCAL || !mParent) 531 { 544 Quaternion rotQuat = currentDir.getRotationTo(targetDir); 545 targetOrientation = rotQuat * currentOrient; 546 } 547 } 548 549 // Set target orientation, transformed to parent space 550 if (mParent) 551 setOrientation(mParent->_getDerivedOrientation().UnitInverse() * targetOrientation); 552 else 532 553 setOrientation(targetOrientation); 533 }534 else535 {536 if (relativeTo == TS_PARENT)537 {538 setOrientation(targetOrientation * mParent->getOrientation().Inverse());539 }540 else if (relativeTo == TS_WORLD)541 {542 setOrientation(targetOrientation * mParent->_getDerivedOrientation().Inverse());543 }544 }545 546 547 554 } 548 555 //----------------------------------------------------------------------- … … 550 557 const Vector3& localDirectionVector) 551 558 { 552 this->setDirection(targetPoint - _getDerivedPosition(), relativeTo, 553 localDirectionVector); 559 // Calculate ourself origin relative to the given transform space 560 Vector3 origin; 561 switch (relativeTo) 562 { 563 default: // Just in case 564 case TS_WORLD: 565 origin = _getDerivedPosition(); 566 break; 567 case TS_PARENT: 568 origin = mPosition; 569 break; 570 case TS_LOCAL: 571 origin = Vector3::ZERO; 572 break; 573 } 574 575 setDirection(targetPoint - origin, relativeTo, localDirectionVector); 554 576 } 555 577 //----------------------------------------------------------------------- -
OGRE/trunk/ogre_changes/Plugins/OctreeSceneManager/include/OgreTerrainRenderable.h
r316 r657 290 290 291 291 /** Overridden from MovableObject */ 292 Real getBoundingRadius(void) const { return 0; /* not needed */}292 Real getBoundingRadius(void) const { return mBoundingRadius; } 293 293 294 294 /** @copydoc Renderable::getLights */ … … 383 383 /// Connection to tiles four neighbours 384 384 TerrainRenderable *mNeighbors [ 4 ]; 385 /// Whether light list need to re-calculate 386 mutable bool mLightListDirty; 387 /// Cached light list 388 mutable LightList mLightList; 389 /// The bounding radius of this tile 390 Real mBoundingRadius; 385 391 /// Bounding box of this tile 386 392 AxisAlignedBox mBounds; -
OGRE/trunk/ogre_changes/Plugins/OctreeSceneManager/src/OgreOctreeSceneManager.cpp
r318 r657 536 536 SceneNode * OctreeSceneManager::createSceneNode( const String &name ) 537 537 { 538 // Check name not used 539 if (mSceneNodes.find(name) != mSceneNodes.end()) 540 { 541 OGRE_EXCEPT( 542 Exception::ERR_DUPLICATE_ITEM, 543 "A scene node with the name " + name + " already exists", 544 "OctreeSceneManager::createSceneNode" ); 545 } 538 546 OctreeNode * on = new OctreeNode( this, name ); 539 547 mSceneNodes[ on->getName() ] = on; … … 548 556 void OctreeSceneManager::_alertVisibleObjects( void ) 549 557 { 558 OGRE_EXCEPT( Exception::UNIMPLEMENTED_FEATURE, 559 "Function doesn't do as advertised", 560 "OctreeSceneManager::_alertVisibleObjects" ); 561 550 562 NodeList::iterator it = mVisible.begin(); 551 563 … … 570 582 571 583 if ( c != 0 ) 572 cam = getCamera( "CullCamera" );584 cam = c; 573 585 } 574 586 … … 680 692 } 681 693 682 if ( octant -> mChildren[ 0 ][ 0 ][ 0 ] != 0 ) 683 walkOctree( camera, queue, octant -> mChildren[ 0 ][ 0 ][ 0 ], ( v == OctreeCamera::FULL ), onlyShadowCasters ); 684 685 if ( octant -> mChildren[ 1 ][ 0 ][ 0 ] != 0 ) 686 walkOctree( camera, queue, octant -> mChildren[ 1 ][ 0 ][ 0 ], ( v == OctreeCamera::FULL ), onlyShadowCasters ); 687 688 if ( octant -> mChildren[ 0 ][ 1 ][ 0 ] != 0 ) 689 walkOctree( camera, queue, octant -> mChildren[ 0 ][ 1 ][ 0 ], ( v == OctreeCamera::FULL ), onlyShadowCasters ); 690 691 if ( octant -> mChildren[ 1 ][ 1 ][ 0 ] != 0 ) 692 walkOctree( camera, queue, octant -> mChildren[ 1 ][ 1 ][ 0 ], ( v == OctreeCamera::FULL ), onlyShadowCasters ); 693 694 if ( octant -> mChildren[ 0 ][ 0 ][ 1 ] != 0 ) 695 walkOctree( camera, queue, octant -> mChildren[ 0 ][ 0 ][ 1 ], ( v == OctreeCamera::FULL ), onlyShadowCasters ); 696 697 if ( octant -> mChildren[ 1 ][ 0 ][ 1 ] != 0 ) 698 walkOctree( camera, queue, octant -> mChildren[ 1 ][ 0 ][ 1 ], ( v == OctreeCamera::FULL ), onlyShadowCasters ); 699 700 if ( octant -> mChildren[ 0 ][ 1 ][ 1 ] != 0 ) 701 walkOctree( camera, queue, octant -> mChildren[ 0 ][ 1 ][ 1 ], ( v == OctreeCamera::FULL ), onlyShadowCasters ); 702 703 if ( octant -> mChildren[ 1 ][ 1 ][ 1 ] != 0 ) 704 walkOctree( camera, queue, octant -> mChildren[ 1 ][ 1 ][ 1 ], ( v == OctreeCamera::FULL ), onlyShadowCasters ); 694 Octree* child; 695 bool childfoundvisible = (v == OctreeCamera::FULL); 696 if ( (child = octant -> mChildren[ 0 ][ 0 ][ 0 ]) != 0 ) 697 walkOctree( camera, queue, child, childfoundvisible, onlyShadowCasters ); 698 699 if ( (child = octant -> mChildren[ 1 ][ 0 ][ 0 ]) != 0 ) 700 walkOctree( camera, queue, child, childfoundvisible, onlyShadowCasters ); 701 702 if ( (child = octant -> mChildren[ 0 ][ 1 ][ 0 ]) != 0 ) 703 walkOctree( camera, queue, child, childfoundvisible, onlyShadowCasters ); 704 705 if ( (child = octant -> mChildren[ 1 ][ 1 ][ 0 ]) != 0 ) 706 walkOctree( camera, queue, child, childfoundvisible, onlyShadowCasters ); 707 708 if ( (child = octant -> mChildren[ 0 ][ 0 ][ 1 ]) != 0 ) 709 walkOctree( camera, queue, child, childfoundvisible, onlyShadowCasters ); 710 711 if ( (child = octant -> mChildren[ 1 ][ 0 ][ 1 ]) != 0 ) 712 walkOctree( camera, queue, child, childfoundvisible, onlyShadowCasters ); 713 714 if ( (child = octant -> mChildren[ 0 ][ 1 ][ 1 ]) != 0 ) 715 walkOctree( camera, queue, child, childfoundvisible, onlyShadowCasters ); 716 717 if ( (child = octant -> mChildren[ 1 ][ 1 ][ 1 ]) != 0 ) 718 walkOctree( camera, queue, child, childfoundvisible, onlyShadowCasters ); 705 719 706 720 } … … 754 768 } 755 769 756 757 758 if ( octant -> mChildren[ 0 ][ 0 ][ 0 ]!= 0 )759 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 0 ][ 0 ]);760 761 if ( octant -> mChildren[ 1 ][ 0 ][ 0 ]!= 0 )762 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 0 ][ 0 ]);763 764 if ( octant -> mChildren[ 0 ][ 1 ][ 0 ]!= 0 )765 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 1 ][ 0 ]);766 767 if ( octant -> mChildren[ 1 ][ 1 ][ 0 ]!= 0 )768 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 1 ][ 0 ]);769 770 if ( octant -> mChildren[ 0 ][ 0 ][ 1 ]!= 0 )771 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 0 ][ 1 ]);772 773 if ( octant -> mChildren[ 1 ][ 0 ][ 1 ]!= 0 )774 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 0 ][ 1 ]);775 776 if ( octant -> mChildren[ 0 ][ 1 ][ 1 ]!= 0 )777 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 1 ][ 1 ]);778 779 if ( octant -> mChildren[ 1 ][ 1 ][ 1 ]!= 0 )780 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 1 ][ 1 ]);770 Octree* child; 771 772 if ( (child=octant -> mChildren[ 0 ][ 0 ][ 0 ]) != 0 ) 773 _findNodes( t, list, exclude, full, child ); 774 775 if ( (child=octant -> mChildren[ 1 ][ 0 ][ 0 ]) != 0 ) 776 _findNodes( t, list, exclude, full, child ); 777 778 if ( (child=octant -> mChildren[ 0 ][ 1 ][ 0 ]) != 0 ) 779 _findNodes( t, list, exclude, full, child ); 780 781 if ( (child=octant -> mChildren[ 1 ][ 1 ][ 0 ]) != 0 ) 782 _findNodes( t, list, exclude, full, child ); 783 784 if ( (child=octant -> mChildren[ 0 ][ 0 ][ 1 ]) != 0 ) 785 _findNodes( t, list, exclude, full, child ); 786 787 if ( (child=octant -> mChildren[ 1 ][ 0 ][ 1 ]) != 0 ) 788 _findNodes( t, list, exclude, full, child ); 789 790 if ( (child=octant -> mChildren[ 0 ][ 1 ][ 1 ]) != 0 ) 791 _findNodes( t, list, exclude, full, child ); 792 793 if ( (child=octant -> mChildren[ 1 ][ 1 ][ 1 ]) != 0 ) 794 _findNodes( t, list, exclude, full, child ); 781 795 782 796 } … … 827 841 } 828 842 829 830 831 if ( octant -> mChildren[ 0 ][ 0 ][ 0 ]!= 0 )832 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 0 ][ 0 ]);833 834 if ( octant -> mChildren[ 1 ][ 0 ][ 0 ]!= 0 )835 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 0 ][ 0 ]);836 837 if ( octant -> mChildren[ 0 ][ 1 ][ 0 ]!= 0 )838 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 1 ][ 0 ]);839 840 if ( octant -> mChildren[ 1 ][ 1 ][ 0 ]!= 0 )841 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 1 ][ 0 ]);842 843 if ( octant -> mChildren[ 0 ][ 0 ][ 1 ]!= 0 )844 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 0 ][ 1 ]);845 846 if ( octant -> mChildren[ 1 ][ 0 ][ 1 ]!= 0 )847 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 0 ][ 1 ]);848 849 if ( octant -> mChildren[ 0 ][ 1 ][ 1 ]!= 0 )850 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 1 ][ 1 ]);851 852 if ( octant -> mChildren[ 1 ][ 1 ][ 1 ]!= 0 )853 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 1 ][ 1 ]);843 Octree* child; 844 845 if ( (child=octant -> mChildren[ 0 ][ 0 ][ 0 ]) != 0 ) 846 _findNodes( t, list, exclude, full, child ); 847 848 if ( (child=octant -> mChildren[ 1 ][ 0 ][ 0 ]) != 0 ) 849 _findNodes( t, list, exclude, full, child ); 850 851 if ( (child=octant -> mChildren[ 0 ][ 1 ][ 0 ]) != 0 ) 852 _findNodes( t, list, exclude, full, child ); 853 854 if ( (child=octant -> mChildren[ 1 ][ 1 ][ 0 ]) != 0 ) 855 _findNodes( t, list, exclude, full, child ); 856 857 if ( (child=octant -> mChildren[ 0 ][ 0 ][ 1 ]) != 0 ) 858 _findNodes( t, list, exclude, full, child ); 859 860 if ( (child=octant -> mChildren[ 1 ][ 0 ][ 1 ]) != 0 ) 861 _findNodes( t, list, exclude, full, child ); 862 863 if ( (child=octant -> mChildren[ 0 ][ 1 ][ 1 ]) != 0 ) 864 _findNodes( t, list, exclude, full, child ); 865 866 if ( (child=octant -> mChildren[ 1 ][ 1 ][ 1 ]) != 0 ) 867 _findNodes( t, list, exclude, full, child ); 854 868 855 869 } … … 901 915 } 902 916 903 904 905 if ( octant -> mChildren[ 0 ][ 0 ][ 0 ]!= 0 )906 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 0 ][ 0 ]);907 908 if ( octant -> mChildren[ 1 ][ 0 ][ 0 ]!= 0 )909 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 0 ][ 0 ]);910 911 if ( octant -> mChildren[ 0 ][ 1 ][ 0 ]!= 0 )912 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 1 ][ 0 ]);913 914 if ( octant -> mChildren[ 1 ][ 1 ][ 0 ]!= 0 )915 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 1 ][ 0 ]);916 917 if ( octant -> mChildren[ 0 ][ 0 ][ 1 ]!= 0 )918 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 0 ][ 1 ]);919 920 if ( octant -> mChildren[ 1 ][ 0 ][ 1 ]!= 0 )921 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 0 ][ 1 ]);922 923 if ( octant -> mChildren[ 0 ][ 1 ][ 1 ]!= 0 )924 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 1 ][ 1 ]);925 926 if ( octant -> mChildren[ 1 ][ 1 ][ 1 ]!= 0 )927 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 1 ][ 1 ]);917 Octree* child; 918 919 if ( (child=octant -> mChildren[ 0 ][ 0 ][ 0 ]) != 0 ) 920 _findNodes( t, list, exclude, full, child ); 921 922 if ( (child=octant -> mChildren[ 1 ][ 0 ][ 0 ]) != 0 ) 923 _findNodes( t, list, exclude, full, child ); 924 925 if ( (child=octant -> mChildren[ 0 ][ 1 ][ 0 ]) != 0 ) 926 _findNodes( t, list, exclude, full, child ); 927 928 if ( (child=octant -> mChildren[ 1 ][ 1 ][ 0 ]) != 0 ) 929 _findNodes( t, list, exclude, full, child ); 930 931 if ( (child=octant -> mChildren[ 0 ][ 0 ][ 1 ]) != 0 ) 932 _findNodes( t, list, exclude, full, child ); 933 934 if ( (child=octant -> mChildren[ 1 ][ 0 ][ 1 ]) != 0 ) 935 _findNodes( t, list, exclude, full, child ); 936 937 if ( (child=octant -> mChildren[ 0 ][ 1 ][ 1 ]) != 0 ) 938 _findNodes( t, list, exclude, full, child ); 939 940 if ( (child=octant -> mChildren[ 1 ][ 1 ][ 1 ]) != 0 ) 941 _findNodes( t, list, exclude, full, child ); 928 942 929 943 } … … 974 988 } 975 989 976 977 978 if ( octant -> mChildren[ 0 ][ 0 ][ 0 ]!= 0 )979 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 0 ][ 0 ]);980 981 if ( octant -> mChildren[ 1 ][ 0 ][ 0 ]!= 0 )982 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 0 ][ 0 ]);983 984 if ( octant -> mChildren[ 0 ][ 1 ][ 0 ]!= 0 )985 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 1 ][ 0 ]);986 987 if ( octant -> mChildren[ 1 ][ 1 ][ 0 ]!= 0 )988 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 1 ][ 0 ]);989 990 if ( octant -> mChildren[ 0 ][ 0 ][ 1 ]!= 0 )991 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 0 ][ 1 ]);992 993 if ( octant -> mChildren[ 1 ][ 0 ][ 1 ]!= 0 )994 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 0 ][ 1 ]);995 996 if ( octant -> mChildren[ 0 ][ 1 ][ 1 ]!= 0 )997 _findNodes( t, list, exclude, full, octant -> mChildren[ 0 ][ 1 ][ 1 ]);998 999 if ( octant -> mChildren[ 1 ][ 1 ][ 1 ]!= 0 )1000 _findNodes( t, list, exclude, full, octant -> mChildren[ 1 ][ 1 ][ 1 ]);990 Octree* child; 991 992 if ( (child=octant -> mChildren[ 0 ][ 0 ][ 0 ]) != 0 ) 993 _findNodes( t, list, exclude, full, child ); 994 995 if ( (child=octant -> mChildren[ 1 ][ 0 ][ 0 ]) != 0 ) 996 _findNodes( t, list, exclude, full, child ); 997 998 if ( (child=octant -> mChildren[ 0 ][ 1 ][ 0 ]) != 0 ) 999 _findNodes( t, list, exclude, full, child ); 1000 1001 if ( (child=octant -> mChildren[ 1 ][ 1 ][ 0 ]) != 0 ) 1002 _findNodes( t, list, exclude, full, child ); 1003 1004 if ( (child=octant -> mChildren[ 0 ][ 0 ][ 1 ]) != 0 ) 1005 _findNodes( t, list, exclude, full, child ); 1006 1007 if ( (child=octant -> mChildren[ 1 ][ 0 ][ 1 ]) != 0 ) 1008 _findNodes( t, list, exclude, full, child ); 1009 1010 if ( (child=octant -> mChildren[ 0 ][ 1 ][ 1 ]) != 0 ) 1011 _findNodes( t, list, exclude, full, child ); 1012 1013 if ( (child=octant -> mChildren[ 1 ][ 1 ][ 1 ]) != 0 ) 1014 _findNodes( t, list, exclude, full, child ); 1001 1015 1002 1016 } … … 1038 1052 1039 1053 mOctree->mBox = box; 1054 1055 const Vector3 min = box.getMinimum(); 1056 const Vector3 max = box.getMaximum(); 1057 mOctree->mHalfSize = ( max - min ) * 0.5f; 1040 1058 1041 1059 it = nodes.begin(); -
OGRE/trunk/ogre_changes/Plugins/OctreeSceneManager/src/OgreTerrainRenderable.cpp
r193 r657 77 77 78 78 mInit = false; 79 mLightListDirty = true; 79 80 MovableObject::mCastShadows = false; 80 81 … … 251 252 ( startz * msOptions->scale.z + (endz - 1) * msOptions->scale.z ) / 2 ); 252 253 254 mBoundingRadius = 255 std::max(max - min, 256 std::max((endx - 1 - startx) * msOptions->scale.x, 257 (endz - 1 - startz) * msOptions->scale.z)) / 2; 258 253 259 // Create delta buffer list if required to morph 254 260 if (msOptions->lodMorph) … … 344 350 345 351 Vector3 cpos = cam -> getDerivedPosition(); 346 Vector3 diff = mCenter - cpos; 352 const AxisAlignedBox& aabb = getWorldBoundingBox(true); 353 Vector3 diff(0, 0, 0); 354 diff.makeFloor(cpos - aabb.getMinimum()); 355 diff.makeCeil(cpos - aabb.getMaximum()); 347 356 348 357 Real L = diff.squaredLength(); … … 443 452 void TerrainRenderable::_updateRenderQueue( RenderQueue* queue ) 444 453 { 454 // Notify need to calculate light list when our sending to render queue 455 mLightListDirty = true; 456 445 457 queue->addRenderable( this ); 446 458 } … … 994 1006 const LightList& TerrainRenderable::getLights(void) const 995 1007 { 996 return getParentSceneNode()->findLights(this->getBoundingRadius()); 1008 if (mLightListDirty) 1009 { 1010 getParentSceneNode()->getCreator()->_populateLightList( 1011 mCenter, this->getBoundingRadius(), mLightList); 1012 mLightListDirty = false; 1013 } 1014 return mLightList; 997 1015 } 998 1016 //----------------------------------------------------------------------- -
OGRE/trunk/ogre_changes/RenderSystems/Direct3D7/include/OgreD3D7RenderWindow.h
r153 r657 119 119 */ 120 120 void writeContentsToFile(const String& filename); 121 121 // DirectDraw Methods 122 void createDDSurfaces(void); 123 void releaseDDSurfaces(void); 124 void restoreDDSurfaces(void); 125 void createDepthBuffer(void); 122 126 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 123 127 uchar *getBufferContents(int &dimx, int &dimy); … … 159 163 LPDIRECT3DDEVICE7 mlpD3DDevice; 160 164 161 // DirectDraw Methods162 void createDDSurfaces(void);163 void releaseDDSurfaces(void);164 void restoreDDSurfaces(void);165 void createDepthBuffer(void);166 165 167 166 // Method for dealing with resize / move & 3d library -
OGRE/trunk/ogre_changes/RenderSystems/Direct3D7/include/OgreD3D7Texture.h
r154 r657 53 53 LPDIRECTDRAWSURFACE7 getDDSurface(void); 54 54 55 /// @copydoc Texture::createInternalResources56 void createInternalResources(void);57 58 55 /// @copydoc Texture::getBuffer 59 56 HardwarePixelBufferSharedPtr getBuffer(size_t face, size_t mipmap); … … 63 60 static PixelFormat closestD3DXFormat( PixelFormat format ); 64 61 static bool OgreFormat_to_DDPixelFormat( PixelFormat format, DDPIXELFORMAT & out ); 62 63 /// Restore this texture from a lost device 64 void restoreFromLostDevice(void); 65 65 66 protected: 66 67 IDirect3DDevice7 * mD3DDevice; ///< A pointer to the Direct3D device. … … 71 72 typedef std::vector<HardwarePixelBufferSharedPtr> SurfaceList; 72 73 SurfaceList mSurfaceList; 74 /// Are we restoring from a lost device? 75 bool mRestoring; 76 73 77 74 78 75 79 /// @copydoc Resource::loadImpl 76 80 void loadImpl(void); 77 /// @copydoc Resource::unloadImpl 78 void unloadImpl(void); 81 /// @copydoc Texture::createInternalResourcesImpl 82 void createInternalResourcesImpl(void); 83 /// @copydoc Resource::freeInternalResourcesImpl 84 void freeInternalResourcesImpl(void); 79 85 80 86 void createSurface2D(void); -
OGRE/trunk/ogre_changes/RenderSystems/Direct3D7/src/OgreD3D7RenderWindow.cpp
r153 r657 96 96 break; 97 97 98 case WM_MOVE:99 // Move messages need to be tracked to update the screen rects100 // used for blitting the backbuffer to the primary.101 if(win->mActive && win->mReady)102 win->windowMovedOrResized();103 break;104 105 98 case WM_ENTERSIZEMOVE: 106 99 // Prevent rendering while moving / sizing … … 113 106 break; 114 107 108 case WM_MOVE: 115 109 case WM_SIZE: 116 110 // Check to see if we are losing or gaining our window. Set the … … 391 385 void D3D7RenderWindow::swapBuffers(bool waitForVSync) 392 386 { 387 if (!mlpDDSFront) 388 return; 389 393 390 HRESULT hr; 394 391 DWORD flags; … … 423 420 { 424 421 // Restore surfaces 425 restoreDDSurfaces();422 //restoreDDSurfaces(); 426 423 } 427 424 else if (FAILED(hr)) … … 539 536 ddscaps.dwCaps = DDSCAPS_ZBUFFER; 540 537 538 if (!mlpDDSBack->IsLost()) 539 { 541 540 LPDIRECTDRAWSURFACE7 zBufSurface; 542 541 … … 546 545 zBufSurface->Release(); 547 546 zBufSurface->Release(); 547 } 548 548 549 549 // Release std buffers … … 563 563 564 564 if( FAILED( hr ) ) 565 { 566 if (hr == DDERR_WRONGMODE) 567 { 568 // Fullscreen exclusive mode problem 569 // Need to release & recreate 570 releaseDDSurfaces(); 571 createDDSurfaces(); 572 createDepthBuffer(); 573 return; 574 } 575 else 576 { 577 char szBuffer[512]; 578 D3DXGetErrorString( hr, 512, szBuffer ); 565 579 OGRE_EXCEPT( 566 580 Exception::ERR_INTERNAL_ERROR, 567 "Error restoring lost primary surface.",581 "Error restoring lost primary surface." + String(szBuffer), 568 582 "D3D7RenderWindow - restoreDDSurfaces" ); 569 583 } 584 } 585 } 570 586 571 587 if( mlpDDSBack->IsLost() ) … … 574 590 575 591 if( FAILED( hr ) ) 592 { 593 char szBuffer[512]; 594 D3DXGetErrorString( hr, 512, szBuffer ); 576 595 OGRE_EXCEPT( 577 596 Exception::ERR_INTERNAL_ERROR, 578 "Error restoring lost back buffer surface." ,597 "Error restoring lost back buffer surface." + String(szBuffer), 579 598 "D3D7RenderWindow - restoreDDSurfaces" ); 580 599 } 600 } 581 601 } 582 602 … … 592 612 ClientToScreen( mHWnd, (POINT*)&rcCheck.left ); 593 613 ClientToScreen( mHWnd, (POINT*)&rcCheck.right ); 614 615 if ((rcCheck.right - rcCheck.left) == 0 || 616 (rcCheck.bottom - rcCheck.top) == 0) 617 { 618 return; 619 } 594 620 595 621 // Has the window resized? If so, we need to recreate surfaces -
OGRE/trunk/ogre_changes/RenderSystems/Direct3D9/include/OgreD3D9HardwareOcclusionQuery.h
r115 r657 34 34 35 35 // If you use multiple rendering passes you can test only the first pass and all other passes don't have to be rendered 36 // if the first pass result ethas too few pixels visible.36 // if the first pass results has too few pixels visible. 37 37 38 // Be sure to render all occlluder first and whats out so the RenderQue don't switch places on38 // Be sure to render all occluder first and whats out so the RenderQue don't switch places on 39 39 // the occluding objects and the tested objects because it thinks it's more effective.. 40 40 … … 46 46 * 47 47 * Updated on 12/7/2004 by Chris McGuirk 48 * Updated on 4/8/2005 by Tuan Kuranes email: tuan.kuranes@free.fr 48 49 */ 49 50 class D3D9HardwareOcclusionQuery : public HardwareOcclusionQuery … … 73 74 bool pullOcclusionQuery( unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag = HWOCCLUSIONQUERY_FLUSH); 74 75 unsigned int getLastQuerysPixelcount() { return mPixelCount; } 76 bool isStillOutstanding(void); 75 77 76 78 // These functions are optional, it's a simple filter that simply skips some hardware occlusion tests on visible objects only … … 82 84 * 83 85 * Remarks This function allows you to set how often the hardware occlusion query is sent to the driver 84 * if you set it to 0 every hw occlusion test is acctually made. If you set it to 1 only the half of your queries are sent85 * 2 will result in 25% of all queries to acctualy be sent.86 * if you set it to 0 every hardware occlusion test is actually made. If you set it to 1 only the half of your queries are sent 87 * 2 will result in 25% of all queries to factually be sent. 86 88 * This functionality is here because this class can keep track on visible and none visible objects for you. 87 89 * Once you you set the SkipRate for any hardware occlusion instance it effects all others. 88 90 */ 89 91 90 void setSkipRate( int skip ) { mSkipInterval = skip; } // Using 2 only 50 % of the tests are actu lly made and 3 results in only 33% of the tests. So on.92 void setSkipRate( int skip ) { mSkipInterval = skip; } // Using 2 only 50 % of the tests are actually made and 3 results in only 33% of the tests. So on. 91 93 int getSkipRate() { return mSkipInterval; } 92 94 … … 105 107 int mSkipInterval; 106 108 bool mHasOcclusionSupport; 109 bool mIsQueryResultStillOutstanding; 107 110 }; 108 111 -
OGRE/trunk/ogre_changes/RenderSystems/Direct3D9/include/OgreD3D9Texture.h
r193 r657 68 68 /// device capabilities pointer 69 69 D3DCAPS9 mDevCaps; 70 // Auto-generated mipmaps?71 bool mAutoGenMipmaps;72 70 // Dynamic textures? 73 71 bool mDynamicTextures; … … 95 93 D3DFORMAT _chooseD3DFormat(); 96 94 97 /// internal method, free D3D9 resources 98 void _freeResources(); 95 /// @copydoc Texture::createInternalResourcesImpl 96 void createInternalResourcesImpl(void); 97 /// free internal resources 98 void freeInternalResourcesImpl(void); 99 99 /// internal method, set Texture class source image protected attributes 100 100 void _setSrcAttributes(unsigned long width, unsigned long height, unsigned long depth, PixelFormat format); … … 116 116 /// internal method, create D3D9HardwarePixelBuffers for every face and 117 117 /// mipmap level. This method must be called after the D3D texture object was created 118 void _createSurfaceList( bool updateOldList=false);118 void _createSurfaceList(void); 119 119 120 120 /// overriden from Resource 121 121 void loadImpl(); 122 /// overriden from Resource123 void unloadImpl();124 122 public: 125 123 /// constructor … … 135 133 void loadImage( const Image &img ); 136 134 137 /// @copydoc Texture::createInternalResources138 void createInternalResources(void);139 135 140 136 /// @copydoc Texture::getBuffer -
OGRE/trunk/ogre_changes/RenderSystems/Direct3D9/src/OgreD3D9HardwareOcclusionQuery.cpp
r193 r657 113 113 // This version of pullOcclusionQuery causes the DX9 API/Driver to not flush all commands to the 3D card 114 114 // to allow a fast result from the query, but the batching of API calls to the card will be normal. 115 // But the query wont be processed until the card rec ives the query in the next batch.115 // But the query wont be processed until the card receives the query in the next batch. 116 116 // Note: OpenGL dosn't use this flag at all so the application running OpenGL won't display any different behaviour. 117 117 //-- -
OGRE/trunk/ogre_changes/RenderSystems/Direct3D9/src/OgreD3D9RenderWindow.cpp
r193 r657 110 110 D3D9RenderWindow::~D3D9RenderWindow() 111 111 { 112 // access and update device through driver, realse only primary 113 if (!mIsSwapChain) 114 { 115 LPDIRECT3DDEVICE9 mpD3DDevice = mDriver->getD3DDevice(); 116 SAFE_RELEASE( mpD3DDevice ); 117 mDriver->setD3DDevice( NULL ); 118 } 112 destroyD3DResources(); 119 113 } 120 114 … … 342 336 md3dpp.BackBufferHeight = mHeight; 343 337 344 #ifdef GTP_VISIBILITY_MODIFIED_OGRE345 //md3dpp.Flags |= D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;346 #endif347 338 if (mVSync) 348 339 md3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE; … … 493 484 // ignore depth buffer, access device through driver 494 485 mpRenderZBuffer = 0; 495 LPDIRECT3DDEVICE9 mpD3DDevice = mDriver->getD3DDevice();496 SAFE_RELEASE(mpD3DDevice);497 mDriver->setD3DDevice(NULL);498 486 } 499 487 } … … 727 715 } 728 716 729 if (!mIsFullScreen) 730 { 731 POINT pt={0, 0}; 717 D3DLOCKED_RECT lockedRect; 718 if(mIsFullScreen) 719 { 720 if (FAILED(hr = pTempSurf->LockRect(&lockedRect, NULL, 721 D3DLOCK_READONLY | D3DLOCK_NOSYSLOCK))) 722 { 723 OGRE_EXCEPT(hr, "can't lock rect!", "D3D9RenderWindow::writeContentsToFile"); 724 } 725 } 726 else 727 { 732 728 RECT srcRect; 733 729 GetWindowRect(mHWnd, &srcRect); … … 735 731 desc.Width = srcRect.right - srcRect.left; 736 732 desc.Height = srcRect.bottom - srcRect.top; 737 desc.Format = D3DFMT_A8R8G8B8; // this is what we get from the screen, so stick with it 738 739 // NB we can't lock the back buffer direct because it's no created that way 740 // and to do so hits performance, so copy to another surface 741 // Must be the same format as the source surface 742 if (FAILED(hr = mpD3DDevice->CreateOffscreenPlainSurface( 743 desc.Width, 744 desc.Height, 745 desc.Format, 746 D3DPOOL_DEFAULT, 747 &pSurf, 748 NULL))) 749 { 750 SAFE_RELEASE(pSurf); 751 OGRE_EXCEPT(hr, "Cannot create offscreen buffer 2!", "D3D9RenderWindow::writeContentsToFile"); 752 } 753 754 // Copy 755 if (FAILED(hr = mpD3DDevice->UpdateSurface(pTempSurf, &srcRect, pSurf, &pt))) 756 { 757 SAFE_RELEASE(pTempSurf); 758 SAFE_RELEASE(pSurf); 759 OGRE_EXCEPT(hr, "Cannot update surface!", "D3D9RenderWindow::writeContentsToFile"); 760 } 761 762 SAFE_RELEASE(pTempSurf); 763 pTempSurf = pSurf; 764 pSurf = NULL; 765 } 766 767 D3DLOCKED_RECT lockedRect; 768 if (FAILED(hr = pTempSurf->LockRect(&lockedRect, NULL, 733 734 if (FAILED(hr = pTempSurf->LockRect(&lockedRect, &srcRect, 735 769 736 D3DLOCK_READONLY | D3DLOCK_NOSYSLOCK))) 770 737 { 771 738 OGRE_EXCEPT(hr, "can't lock rect!", "D3D9RenderWindow::writeContentsToFile"); 772 739 } 740 } 773 741 774 742 ImageCodec::ImageData *imgData = new ImageCodec::ImageData(); -
OGRE/trunk/ogre_changes/RenderSystems/GL/include/OgreGLHardwareOcclusionQuery.h
r343 r657 53 53 54 54 // If you use multiple rendering passes you can test only the first pass and all other passes don't have to be rendered 55 // if the first pass result et has too few pixels visable.55 // if the first pass result has too few pixels visible. 56 56 57 // Be sure to render all occl luder first and whats out so the RenderQue don't switch places on57 // Be sure to render all occluder first and whats out so the RenderQue don't switch places on 58 58 // the occluding objects and the tested objects because it thinks it's more effective.. 59 59 … … 64 64 * 65 65 * @author Lee Sandberg email: lee@abcmedia.se 66 * Updated on 4/8/2005 by Tuan Kuranes email: tuan.kuranes@free.fr 66 67 */ 67 68 … … 91 92 unsigned int getLastQuerysPixelcount() { return mPixelCount; } 92 93 93 // This functions are optional, it's a simple filter that simply skip ps some hardware occlusion tests on visable objects only94 // It's easy to use if you don't have to keep track on which objects are vis able (can be skipped) and what objects arn't visable..95 // (None vis able objects and object you introduce for the first time have allways to be tested allthough the cheepest possible96 // LOD (Level Of Detail) mesh and material wi ze).94 // This functions are optional, it's a simple filter that simply skips some hardware occlusion tests on visible objects only 95 // It's easy to use if you don't have to keep track on which objects are visible (can be skipped) and what objects arn't visible.. 96 // (None visible objects and object you introduce for the first time have always to be tested although the cheapest possible 97 // LOD (Level Of Detail) mesh and material wise). 97 98 98 99 /** 99 100 * 100 101 * Remarks This function allows you to set how often the hardware occlusion really sent to the driver 101 * if you set it to 0 every h w occlusion test is acctually made. If you set it to 2 only 50% of your queries are sent.102 * for all vis able objects. 3 will result in 33% of all queries to acctualy be sent and so on.103 * New and none vis able objects will be tested all the time.104 * This functionality is here because this class can keep track on vis able and none visable objects for you.102 * if you set it to 0 every hardware occlusion test is actually made. If you set it to 2 only 50% of your queries are sent. 103 * for all visible objects. 3 will result in 33% of all queries to actually be sent and so on. 104 * New and none visible objects will be tested all the time. 105 * This functionality is here because this class can keep track on visible and none visible objects for you. 105 106 * Once you you set the SkipRate for any hardware occlusion instance it effects all others. 106 107 */ 107 108 108 void setSkipRate( int skip ) { mSkipInterval = skip; } // Using 2 only 50 % of the tests are actu lly made and 3 results in only 33% of the tests. So on.109 void setSkipRate( int skip ) { mSkipInterval = skip; } // Using 2 only 50 % of the tests are actually made and 3 results in only 33% of the tests. So on. 109 110 int getSkipRate() { return mSkipInterval; } 110 111 -
OGRE/trunk/ogre_changes/RenderSystems/GL/include/OgreGLTexture.h
r153 r657 46 46 virtual ~GLTexture(); 47 47 48 /// @copydoc Texture::createInternalResources49 void createInternalResources(void);50 48 void loadImage( const Image& img ); 51 49 void createRenderTexture(); … … 61 59 62 60 protected: 61 /// @copydoc Texture::createInternalResourcesImpl 62 void createInternalResourcesImpl(void); 63 63 /// @copydoc Resource::loadImpl 64 64 void loadImpl(void); 65 /// @copydoc Resource:: unloadImpl66 void unloadImpl(void);65 /// @copydoc Resource::freeInternalResourcesImpl 66 void freeInternalResourcesImpl(void); 67 67 68 68 /** internal method, create GLHardwarePixelBuffers for every face and -
OGRE/trunk/ogre_changes/RenderSystems/GL/src/OgreGLHardwareOcclusionQuery.cpp
r343 r657 38 38 * Updated on 12/7/2004 by Chris McGuirk 39 39 * - Implemented ARB_occlusion_query 40 * Updated on 4/8/2005 by Tuan Kuranes email: tuan.kuranes@free.fr 40 41 */ 41 42 … … 154 155 #endif // GTP_VIBILITY_MODIFIED_OGRE 155 156 } 157 158 -
OGRE/trunk/ogre_changes/RenderSystems/GL/src/OgreGLRenderSystem.cpp
r350 r657 257 257 delete mTextureManager; 258 258 259 delete mCapabilities;260 259 delete mGLSupport; 261 260 } … … 894 893 case Light::LT_SPOTLIGHT: 895 894 glLightf( gl_index, GL_SPOT_CUTOFF, 0.5f * lt->getSpotlightOuterAngle().valueDegrees() ); 895 glLightf(gl_index, GL_SPOT_EXPONENT, lt->getSpotlightFalloff()); 896 896 break; 897 897 default: … … 1090 1090 if(!tex.isNull()) 1091 1091 glBindTexture( mTextureTypes[stage], tex->getGLID() ); 1092 1092 else 1093 glBindTexture( mTextureTypes[stage], static_cast<GLTextureManager*>(mTextureManager)->getWarningTextureID() ); 1093 1094 } 1094 1095 else … … 1238 1239 1239 1240 // Set scale and translation matrix for projective textures 1240 projectionBias = Matrix4::ZERO; 1241 projectionBias[0][0] = 0.5; projectionBias[1][1] = -0.5; 1242 projectionBias[2][2] = 1.0; projectionBias[0][3] = 0.5; 1243 projectionBias[1][3] = 0.5; projectionBias[3][3] = 1.0; 1241 projectionBias = Matrix4::CLIPSPACE2DTOIMAGESPACE; 1244 1242 1245 1243 projectionBias = projectionBias * frustum->getProjectionMatrix(); … … 1260 1258 switch(tam) 1261 1259 { 1260 default: 1262 1261 case TextureUnitState::TAM_WRAP: 1263 1262 type = GL_REPEAT; … … 1295 1294 mat[12] = mat[8]; 1296 1295 mat[13] = mat[9]; 1296 mat[8] = 0; 1297 mat[9] = 0; 1297 1298 } 1298 1299 // mat[14] = mat[10]; … … 1312 1313 glMatrixMode(GL_TEXTURE); 1313 1314 1315 // Load this matrix in 1316 glLoadMatrixf(mat); 1317 1314 1318 if (mUseAutoTextureMatrix) 1315 1319 { 1316 // Load auto matrix in 1317 glLoadMatrixf(mAutoTextureMatrix); 1318 // Concat new matrix 1319 glMultMatrixf(mat); 1320 1321 } 1322 else 1323 { 1324 // Just load this matrix 1325 glLoadMatrixf(mat); 1320 // Concat auto matrix 1321 glMultMatrixf(mAutoTextureMatrix); 1326 1322 } 1327 1323 … … 1403 1399 h = vp->getActualHeight(); 1404 1400 x = vp->getActualLeft(); 1405 y = target->getHeight() - vp->getActualTop() - h; 1406 1401 y = vp->getActualTop(); 1402 if (!target->requiresTextureFlipping()) 1403 { 1404 // Convert "upper-left" corner to "lower-left" 1405 y = target->getHeight() - h - y; 1406 } 1407 1407 glViewport(x, y, w, h); 1408 1408 … … 2344 2344 glDisableVertexAttribArrayARB_ptr(1); // disable weights 2345 2345 } 2346 2346 glColor4f(1,1,1,1); 2347 2347 glSecondaryColor3fEXT_ptr(0.0f, 0.0f, 0.0f); 2348 2348 … … 2415 2415 const Plane& plane = clipPlanes[i]; 2416 2416 2417 if (i >= GL_MAX_CLIP_PLANES)2417 if (i >= 6/*GL_MAX_CLIP_PLANES*/) 2418 2418 { 2419 2419 OGRE_EXCEPT(0, "Unable to set clip plane", … … 2424 2424 clipPlane[1] = plane.normal.y; 2425 2425 clipPlane[2] = plane.normal.z; 2426 clipPlane[3] = -plane.d;2426 clipPlane[3] = plane.d; 2427 2427 2428 2428 glClipPlane(clipPlaneId, clipPlane); … … 2440 2440 size_t top, size_t right, size_t bottom) 2441 2441 { 2442 // If request texture flipping, use "upper-left", otherwise use "lower-left" 2443 bool flipping = mActiveRenderTarget->requiresTextureFlipping(); 2442 2444 // GL measures from the bottom, not the top 2443 2445 size_t targetHeight = mActiveRenderTarget->getHeight(); … … 2450 2452 // NB GL uses width / height rather than right / bottom 2451 2453 x = left; 2454 if (flipping) 2455 y = top; 2456 else 2452 2457 y = targetHeight - bottom; 2453 2458 w = right - left; … … 2462 2467 h = mActiveViewport->getActualHeight(); 2463 2468 x = mActiveViewport->getActualLeft(); 2469 if (flipping) 2470 y = mActiveViewport->getActualTop(); 2471 else 2464 2472 y = targetHeight - mActiveViewport->getActualTop() - h; 2465 2473 glScissor(x, y, w, h); … … 2575 2583 HardwareOcclusionQuery* GLRenderSystem::createHardwareOcclusionQuery(void) 2576 2584 { 2577 return new GLHardwareOcclusionQuery(); 2585 GLHardwareOcclusionQuery* ret = new GLHardwareOcclusionQuery(); 2586 mHwOcclusionQueries.push_back(ret); 2587 return ret; 2578 2588 } 2579 2589 //--------------------------------------------------------------------- … … 2639 2649 } 2640 2650 //--------------------------------------------------------------------- 2651 void GLRenderSystem::_switchContext(GLContext *context) 2652 { 2653 // Unbind GPU programs and rebind to new context later, because 2654 // scene manager treat render system as ONE 'context' ONLY, and it 2655 // cached the GPU programs using state. 2656 if (mCurrentVertexProgram) 2657 mCurrentVertexProgram->unbindProgram(); 2658 if (mCurrentFragmentProgram) 2659 mCurrentFragmentProgram->unbindProgram(); 2660 2661 // It's ready to switching 2662 mCurrentContext->endCurrent(); 2663 mCurrentContext = context; 2664 mCurrentContext->setCurrent(); 2665 2666 // Check if the context has already done one-time initialisation 2667 if(!mCurrentContext->getInitialized()) 2668 { 2669 _oneTimeContextInitialization(); 2670 mCurrentContext->setInitialized(); 2671 } 2672 2673 // Rebind GPU programs to new context 2674 if (mCurrentVertexProgram) 2675 mCurrentVertexProgram->bindProgram(); 2676 if (mCurrentFragmentProgram) 2677 mCurrentFragmentProgram->bindProgram(); 2678 2679 // Must reset depth/colour write mask to according with user desired, otherwise, 2680 // clearFrameBuffer would be wrong because the value we are recorded may be 2681 // difference with the really state stored in GL context. 2682 glDepthMask(mDepthWrite); 2683 glColorMask(mColourWrite[0], mColourWrite[1], mColourWrite[2], mColourWrite[3]); 2684 2685 } 2686 //--------------------------------------------------------------------- 2641 2687 void GLRenderSystem::_setRenderTarget(RenderTarget *target) 2642 2688 { … … 2645 2691 ContextMap::iterator i = mContextMap.find(target); 2646 2692 if(i != mContextMap.end() && mCurrentContext != i->second) { 2647 mCurrentContext->endCurrent(); 2648 mCurrentContext = i->second; 2649 // Check if the context has already done one-time initialisation 2650 if(!mCurrentContext->getInitialized()) { 2651 _oneTimeContextInitialization(); 2652 mCurrentContext->setInitialized(); 2653 } 2654 mCurrentContext->setCurrent(); 2693 _switchContext(i->second); 2655 2694 } 2656 2695 } … … 2669 2708 // we set the main context to 0. 2670 2709 if(mCurrentContext != mMainContext) { 2671 mCurrentContext->endCurrent(); 2672 mCurrentContext = mMainContext; 2673 mCurrentContext->setCurrent(); 2710 _switchContext(mMainContext); 2674 2711 } else { 2675 2712 mMainContext = 0; -
OGRE/trunk/ogre_changes/RenderSystems/GL/src/OgreGLTexture.cpp
r193 r657 69 69 // have to call this here reather than in Resource destructor 70 70 // since calling virtual methods in base destructors causes crash 71 if (mIsLoaded) 72 { 71 73 unload(); 74 } 75 else 76 { 77 freeInternalResources(); 78 } 72 79 } 73 80 … … 90 97 91 98 //* Creation / loading methods ******************************************** 92 void GLTexture::createInternalResources (void)99 void GLTexture::createInternalResourcesImpl(void) 93 100 { 94 101 // Adjust requested parameters to capabilities … … 131 138 // Zero means create mip levels until 1x1 132 139 size_t maxMips = GLPixelUtil::getMaxMipmaps(mWidth, mHeight, mDepth, mFormat); 140 mNumMipmaps = mNumRequestedMipmaps; 133 141 if(mNumMipmaps>maxMips) 134 142 mNumMipmaps = maxMips; … … 144 152 145 153 // If we can do automip generation and the user desires this, do so 154 mMipmapsHardwareGenerated = 155 Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_AUTOMIPMAP); 146 156 if((mUsage & TU_AUTOMIPMAP) && 147 mNumMipmaps && 148 Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_AUTOMIPMAP)) 157 mNumRequestedMipmaps && mMipmapsHardwareGenerated) 149 158 { 150 159 glTexParameteri( getGLTextureTarget(), GL_GENERATE_MIPMAP, GL_TRUE ); … … 242 251 // Get final internal format 243 252 mFormat = getBuffer(0,0)->getFormat(); 244 mIsLoaded = true;245 253 } 246 254 … … 326 334 //************************************************************************* 327 335 328 void GLTexture:: unloadImpl()336 void GLTexture::freeInternalResourcesImpl() 329 337 { 330 338 mSurfaceList.clear(); … … 337 345 { 338 346 mSurfaceList.clear(); 339 // Make our understanding of the number of mips matches the GL one340 glBindTexture( getGLTextureTarget(), mTextureID );341 GLint value;342 glGetTexParameteriv( getGLTextureTarget(), GL_TEXTURE_MAX_LEVEL, &value );343 mNumMipmaps = value;344 347 345 348 // For all faces and mipmaps, store surfaces as HardwarePixelBufferSharedPtr 346 349 bool wantGeneratedMips = (mUsage & TU_AUTOMIPMAP)!=0; 347 bool canMip = Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_AUTOMIPMAP);348 350 349 351 // Do mipmapping in software? (uses GLU) For some cards, this is still needed. Of course, 350 352 // only when mipmap generation is desired. 351 bool doSoftware = wantGeneratedMips && ! canMip&& getNumMipmaps();353 bool doSoftware = wantGeneratedMips && !mMipmapsHardwareGenerated && getNumMipmaps(); 352 354 353 355 for(int face=0; face<getNumFaces(); face++) -
OGRE/trunk/ogre_changes/RenderSystems/GL/src/OgreWin32Window.cpp
r193 r657 226 226 } 227 227 228 HDC old_hdc = wglGetCurrentDC(); 229 HGLRC old_context = wglGetCurrentContext(); 230 228 231 RECT rc; 229 232 // top and left represent outer window position … … 255 258 256 259 wglSwapIntervalEXT(vsync? 1 : 0); 260 261 if (old_context) 262 { 263 // Restore old context 264 if (!wglMakeCurrent(old_hdc, old_context)) 265 OGRE_EXCEPT(0, "wglMakeCurrent() failed", "Win32Window::create"); 266 267 // Share lists with old context 268 if (!wglShareLists(old_context, mGlrc)) 269 OGRE_EXCEPT(0, "wglShareLists() failed", " Win32Window::create"); 270 } 257 271 258 272 // Create RenderSystem context
Note: See TracChangeset
for help on using the changeset viewer.