Panagiotis Christopoulos Charitos 13 years ago
parent
commit
8432ca657d

+ 1 - 1
include/anki/math/Mat4.inl.h

@@ -999,4 +999,4 @@ inline std::ostream& operator<<(std::ostream& s, const Mat4& m)
 	return s;
 	return s;
 }
 }
 
 
-} // end namespace
+} // end namespace anki

+ 11 - 1
include/anki/math/Vec4.inl.h

@@ -430,13 +430,23 @@ inline F32 Vec4::getLength() const
 // getNormalized
 // getNormalized
 inline Vec4 Vec4::getNormalized() const
 inline Vec4 Vec4::getNormalized() const
 {
 {
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
+	__m128 inverse_norm = _mm_rsqrt_ps(_mm_dp_ps(mm, mm, 0xFF));
+	return Vec4(_mm_mul_ps(mm, inverse_norm));
+#else
 	return (*this) / getLength();
 	return (*this) / getLength();
+#endif
 }
 }
 
 
 // normalize
 // normalize
 inline void Vec4::normalize()
 inline void Vec4::normalize()
 {
 {
+#if ANKI_MATH_SIMD == ANKI_MATH_SIMD_SSE
+	__m128 inverseNorm = _mm_rsqrt_ps(_mm_dp_ps(mm, mm, 0xFF));
+	mm = _mm_mul_ps(mm, inverseNorm);
+#else
 	(*this) /= getLength();
 	(*this) /= getLength();
+#endif
 }
 }
 
 
 //==============================================================================
 //==============================================================================
@@ -474,4 +484,4 @@ inline std::ostream& operator<<(std::ostream& s, const Vec4& v)
 	return s;
 	return s;
 }
 }
 
 
-} // end namespace
+} // end namespace anki

+ 11 - 0
include/anki/renderer/Tiler.h

@@ -66,6 +66,15 @@ private:
 		/// @}
 		/// @}
 	};
 	};
 
 
+	/// XXX
+	struct Tile_
+	{
+		Vec3 min;
+		Vec3 max;
+		U32 mask[2];
+		I16 children[4]; ///< Use small index to save memory
+	};
+
 	typedef F32 PixelArray[TILES_Y_COUNT][TILES_X_COUNT][2];
 	typedef F32 PixelArray[TILES_Y_COUNT][TILES_X_COUNT][2];
 
 
 	/// @note The [0][0] is the bottom left tile
 	/// @note The [0][0] is the bottom left tile
@@ -98,6 +107,8 @@ private:
 
 
 	void initInternal(Renderer* r);
 	void initInternal(Renderer* r);
 
 
+	void initTileDepth(Tile_* tiles, U depth);
+
 	Bool testInternal(const CollisionShape& cs, const Tile& tile, 
 	Bool testInternal(const CollisionShape& cs, const Tile& tile, 
 		const U startPlane) const;
 		const U startPlane) const;
 };
 };

+ 1 - 1
src/renderer/Dbg.cpp

@@ -41,7 +41,7 @@ void Dbg::init(const Renderer::Initializer& initializer)
 Bool isLeft(const Vec2& p0, const Vec2& p1, const Vec2& p2)
 Bool isLeft(const Vec2& p0, const Vec2& p1, const Vec2& p2)
 {
 {
 	return (p1.x() - p0.x()) * (p2.y() - p0.y())
 	return (p1.x() - p0.x()) * (p2.y() - p0.y())
-		- (p2.x() - p0.x()) * (p1.y() - p0.y()) > 0.0;
+		> (p2.x() - p0.x()) * (p1.y() - p0.y());
 }
 }
 
 
 void calcConvexHull2D(const Vec2* ANKI_RESTRICT points, 
 void calcConvexHull2D(const Vec2* ANKI_RESTRICT points,