Commit d6f8edae authored by hybrid's avatar hybrid

A first few fixes concerning strict-aliasing mentioned by vapier.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@864 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 09e39659
......@@ -79,31 +79,32 @@ namespace core
isOnSameSide(p, pointC, pointA, pointB));
}
//! Check if a point is inside the triangle. This method is an implementation
//! of the example used in a paper by Kasper Fauerby original written
//! by Keidy from Mr-Gamemaker.
//! \param p: Point to test. Assumes that this point is already on the plane
//! of the triangle.
//! \return Returns true if the point is inside the triangle, otherwise false.
//! Check if a point is inside the triangle. This method is an
//! implementation of the example used in a paper by Kasper
//! Fauerby original written by Keidy from Mr-Gamemaker.
//! \param p: Point to test. Assumes that this point is already
//! on the plane of the triangle.
//! \return Returns true if the point is inside the triangle,
//! otherwise false.
bool isPointInsideFast(const vector3d<T>& p) const
{
vector3d<T> f = pointB - pointA;
vector3d<T> g = pointC - pointA;
const vector3d<T> f = pointB - pointA;
const vector3d<T> g = pointC - pointA;
f32 a = f.dotProduct(f);
f32 b = f.dotProduct(g);
f32 c = g.dotProduct(g);
const f32 a = f.dotProduct(f);
const f32 b = f.dotProduct(g);
const f32 c = g.dotProduct(g);
f32 ac_bb = (a*c)-(b*b);
vector3d<T> vp = p - pointA;
const vector3d<T> vp = p - pointA;
const f32 d = vp.dotProduct(f);
const f32 e = vp.dotProduct(g);
f32 d = vp.dotProduct(f);
f32 e = vp.dotProduct(g);
f32 x = (d*c)-(e*b);
f32 y = (e*a)-(d*b);
const f32 ac_bb = (a*c)-(b*b);
f32 z = x+y-ac_bb;
return (( ((u32&)z)& ~(((u32&)x)|((u32&)y))) & 0x80000000)!=0;
return (( (IR(z)) & ~((IR(x))|(IR(y))) ) & 0x80000000)!=0;
}
......
......@@ -18,12 +18,7 @@ namespace core
{
public:
#ifdef IRRLICHT_FAST_MATH
vector3d() {};
#else
vector3d() : X(0), Y(0), Z(0) {};
#endif
vector3d(T nx, T ny, T nz) : X(nx), Y(ny), Z(nz) {};
vector3d(const vector3d<T>& other) : X(other.X), Y(other.Y), Z(other.Z) {};
......
......@@ -150,10 +150,16 @@ IImage* CImageLoaderPng::loadImage(irr::io::IReadFile* file)
png_read_info(png_ptr, info_ptr); // Read the info section of the png file
// Extract info
png_get_IHDR(png_ptr, info_ptr,
(png_uint_32*)&Width, (png_uint_32*)&Height,
&BitDepth, &ColorType, NULL, NULL, NULL);
{
// Use temporary variables to avoid passing casted pointers
png_uint_32 w,h;
// Extract info
png_get_IHDR(png_ptr, info_ptr,
&w, &h,
&BitDepth, &ColorType, NULL, NULL, NULL);
Width=w;
Height=h;
}
// Convert palette color to true color
if (ColorType==PNG_COLOR_TYPE_PALETTE)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment