Browse Source

Optimized Color::ToUInt().

Lasse Öörni 13 năm trước cách đây
mục cha
commit
c25d16b14e

+ 6 - 6
Engine/Math/Color.h

@@ -114,14 +114,14 @@ public:
         );
     }
     
-    /// Return color packed to a 32-bit integer. Only the range [0, 1] is supported for components.
+    /// Return color packed to a 32-bit integer. Components are clamped to [0, 1] range.
     unsigned ToUInt() const
     {
-        unsigned r = (unsigned)(Clamp(r_ * 255.0f, 0.0f, 255.0f));
-        unsigned g = (unsigned)(Clamp(g_ * 255.0f, 0.0f, 255.0f));
-        unsigned b = (unsigned)(Clamp(b_ * 255.0f, 0.0f, 255.0f));
-        unsigned a = (unsigned)(Clamp(a_ * 255.0f, 0.0f, 255.0f));
-        return (((a) & 0xff) << 24) | (((b) & 0xff) << 16) | (((g) & 0xff) << 8) | ((r) & 0xff);
+        int r = Clamp((int)(r_ * 255.0f), 0, 255);
+        int g = Clamp((int)(g_ * 255.0f), 0, 255);
+        int b = Clamp((int)(b_ * 255.0f), 0, 255);
+        int a = Clamp((int)(b_ * 255.0f), 0, 255);
+        return (a << 24) | (b << 16) | (g << 8) | r;
     }
     
     /// Return as a four-dimensional vector.

+ 4 - 4
ThirdParty/AngelScript/source/as_callfunc_x86.cpp

@@ -28,7 +28,7 @@
    [email protected]
 */
 
-// Modified by Lasse Öörni for Urho3D
+// Modified by Lasse Öörni for Urho3D
 
 //
 // as_callfunc_x86.cpp
@@ -115,11 +115,11 @@ asQWORD CallSystemFunctionNative(asCContext *context, asCScriptFunction *descr,
 	// away the assignment of the return code on Mac OS X. 
 	// ref: http://www.gamedev.net/topic/621357-porting-dustforce-to-os-x/
 
-    // Urho3D: do not apply this fix on Linux, as it causes problems in release builds
+	// Urho3D: do not apply this fix on Linux, as it causes problems in release builds
 #ifndef __linux__
 	volatile asQWORD retQW = 0;
-#else    
-    asQWORD retQW = 0;
+#else
+	asQWORD retQW = 0;
 #endif
 
 	// Prepare the parameters

+ 6 - 2
ThirdParty/Bullet/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp

@@ -13,6 +13,8 @@ subject to the following restrictions:
 3. This notice may not be removed or altered from any source distribution.
 */
 
+// Modified by Lasse Öörni for Urho3D
+
 #include "btCollisionWorld.h"
 #include "btCollisionDispatcher.h"
 #include "BulletCollision/CollisionDispatch/btCollisionObject.h"
@@ -1197,10 +1199,12 @@ public:
 		  wv0 = m_worldTrans*triangle[0];
 		  wv1 = m_worldTrans*triangle[1];
 		  wv2 = m_worldTrans*triangle[2];
-		  btVector3 center = (wv0+wv1+wv2)*btScalar(1./3.);
-          
+
           if (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawNormals )
           {
+		    // Urho3D: calculate center only if needed
+		    btVector3 center = (wv0+wv1+wv2)*btScalar(1./3.);
+          
 		    btVector3 normal = (wv1-wv0).cross(wv2-wv0);
 		    normal.normalize();
 		    btVector3 normalColor(1,1,0);