Commit 40480a78 authored by hybrid's avatar hybrid

Merged revisions 4001-4056 from 1.7 branch. Keycode updates, fix compilation...

Merged revisions 4001-4056 from 1.7 branch. Keycode updates, fix compilation errors, vector normalize error case fixed, joystick safety fixes, editbox updates, meshviewer modal window fix, isPointInsideFast changes.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4057 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 66a6bbde
...@@ -293,12 +293,30 @@ The following names can be queried for the given types: ...@@ -293,12 +293,30 @@ The following names can be queried for the given types:
----------------------------- -----------------------------
Changes in 1.7.3 (??.??.2011) Changes in 1.7.3 (??.??.2011)
- Document that triangle3d::isPointInside should not be used with int's.
- triangle3d::isPointInsideFast handles 'on-border' cases now consistently.
- Bugfix: vector2d.normalize() and vector3d.normalize() had returned wrong results with very short vectors since Irrlicht 1.5. Thanks to Willem Swart for Bugreport + testcase.
- Unknown keymappings now use the X11 keycode instead of 0 to make such keys at least usable in games.
- KeyMapping for KeyInput.Key on X11 ignores states like shift&ctrl now like on Windows.
- Additional keymappings for X11 (tested with german and us keyboards which seem to work now in all cases).
- Fix crash in multiline editbox when pasting several lines into it on Windows.
- example 09.Meshviewer no longer catches keys while a modal dialog is open
- editbox no longer displays cursor when disabled
- editbox autoscrolling now at least works good enough to actually show the text which the user is typing in.
- editbox no longer moves text into next line when it fails wrapping creating senseless empty lines which mess up scrolling. - editbox no longer moves text into next line when it fails wrapping creating senseless empty lines which mess up scrolling.
- Fix crash in editbox when scrolling up with empty first lines caused by textwrapping. - Fix crash in editbox when scrolling up with empty first lines caused by textwrapping.
- triangle3d::isPointInside can now work with larger integers, old version failed already with values in the 3-digit range. It got also faster. (thx @ Eigen for report + testcase and REDDemon for patch proposal).
- Fix focus problem when removing an unfocused modal dialog reported by Reiko here: http://irrlicht.sourceforge.net/forum/viewtopic.php?f=7&t=44358 - Fix focus problem when removing an unfocused modal dialog reported by Reiko here: http://irrlicht.sourceforge.net/forum/viewtopic.php?f=7&t=44358
- Add integer template specialization for vector3d::getSphericalCoordinateAngles which rounds angles to nearest integer now. - Add integer template specialization for vector3d::getSphericalCoordinateAngles which rounds angles to nearest integer now.
......
...@@ -147,8 +147,7 @@ void updateScaleInfo(scene::ISceneNode* model) ...@@ -147,8 +147,7 @@ void updateScaleInfo(scene::ISceneNode* model)
} }
/* /*
The three following functions do several stuff used by the mesh viewer. The Function showAboutText() displays a messagebox with a caption and
first function showAboutText() simply displays a messagebox with a caption and
a message text. The texts will be stored in the MessageText and Caption a message text. The texts will be stored in the MessageText and Caption
variables at startup. variables at startup.
*/ */
...@@ -162,7 +161,7 @@ void showAboutText() ...@@ -162,7 +161,7 @@ void showAboutText()
/* /*
The second function loadModel() loads a model and displays it using an Function loadModel() loads a model and displays it using an
addAnimatedMeshSceneNode and the scene manager. Nothing difficult. It also addAnimatedMeshSceneNode and the scene manager. Nothing difficult. It also
displays a short message box, if the model could not be loaded. displays a short message box, if the model could not be loaded.
*/ */
...@@ -259,7 +258,7 @@ void loadModel(const c8* fn) ...@@ -259,7 +258,7 @@ void loadModel(const c8* fn)
/* /*
Finally, the third function creates a toolbox window. In this simple mesh Function createToolBox() creates a toolbox window. In this simple mesh
viewer, this toolbox only contains a tab control with three edit boxes for viewer, this toolbox only contains a tab control with three edit boxes for
changing the scale of the displayed model. changing the scale of the displayed model.
*/ */
...@@ -323,6 +322,10 @@ void createToolBox() ...@@ -323,6 +322,10 @@ void createToolBox()
scrollbar->setSmallStep(1); scrollbar->setSmallStep(1);
} }
/*
Function updateToolBox() is called each frame to update dynamic information in
the toolbox.
*/
void updateToolBox() void updateToolBox()
{ {
IGUIEnvironment* env = Device->getGUIEnvironment(); IGUIEnvironment* env = Device->getGUIEnvironment();
...@@ -375,11 +378,27 @@ void onKillFocus() ...@@ -375,11 +378,27 @@ void onKillFocus()
} }
} }
/*
Function hasModalDialog() checks if we currently have a modal dialog open.
*/
bool hasModalDialog()
{
IGUIEnvironment* env = Device->getGUIEnvironment();
IGUIElement * focused = env->getFocus();
while ( focused )
{
if ( focused->isVisible() && focused->hasType(EGUIET_MODAL_SCREEN) )
return true;
focused = focused->getParent();
}
return false;
}
/* /*
To get all the events sent by the GUI Elements, we need to create an event To get all the events sent by the GUI Elements, we need to create an event
receiver. This one is really simple. If an event occurs, it checks the id of receiver. This one is really simple. If an event occurs, it checks the id of
the caller and the event type, and starts an action based on these values. For the caller and the event type, and starts an action based on these values. For
example, if a menu item with id GUI_ID_OPEN_MODEL was selected, if opens a file-open-dialog. example, if a menu item with id GUI_ID_OPEN_MODEL was selected, it opens a file-open-dialog.
*/ */
class MyEventReceiver : public IEventReceiver class MyEventReceiver : public IEventReceiver
{ {
...@@ -503,6 +522,11 @@ public: ...@@ -503,6 +522,11 @@ public:
*/ */
bool OnKeyUp(irr::EKEY_CODE keyCode) bool OnKeyUp(irr::EKEY_CODE keyCode)
{ {
// Don't handle keys if we have a modal dialog open as it would lead
// to unexpected application behaviour for the user.
if ( hasModalDialog() )
return false;
if (keyCode == irr::KEY_ESCAPE) if (keyCode == irr::KEY_ESCAPE)
{ {
if (Device) if (Device)
......
...@@ -788,7 +788,7 @@ funcptr_createDeviceEx load_createDeviceEx ( const c8 * filename) ...@@ -788,7 +788,7 @@ funcptr_createDeviceEx load_createDeviceEx ( const c8 * filename)
#endif #endif
/* /*
get the current collision respone camera animator get the current collision response camera animator
*/ */
ISceneNodeAnimatorCollisionResponse* camCollisionResponse( IrrlichtDevice * device ) ISceneNodeAnimatorCollisionResponse* camCollisionResponse( IrrlichtDevice * device )
{ {
......
...@@ -69,9 +69,9 @@ namespace gui ...@@ -69,9 +69,9 @@ namespace gui
//! Sets text justification mode //! Sets text justification mode
/** \param horizontal: EGUIA_UPPERLEFT for left justified (default), /** \param horizontal: EGUIA_UPPERLEFT for left justified (default),
EGUIA_LOWEERRIGHT for right justified, or EGUIA_CENTER for centered text. EGUIA_LOWERRIGHT for right justified, or EGUIA_CENTER for centered text.
\param vertical: EGUIA_UPPERLEFT to align with top edge, \param vertical: EGUIA_UPPERLEFT to align with top edge,
EGUIA_LOWEERRIGHT for bottom edge, or EGUIA_CENTER for centered text (default). */ EGUIA_LOWERRIGHT for bottom edge, or EGUIA_CENTER for centered text (default). */
virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) = 0; virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) = 0;
//! Enables or disables word wrap. //! Enables or disables word wrap.
......
...@@ -141,10 +141,20 @@ namespace irr ...@@ -141,10 +141,20 @@ namespace irr
KEY_RCONTROL = 0xA3, // Right CONTROL key KEY_RCONTROL = 0xA3, // Right CONTROL key
KEY_LMENU = 0xA4, // Left MENU key KEY_LMENU = 0xA4, // Left MENU key
KEY_RMENU = 0xA5, // Right MENU key KEY_RMENU = 0xA5, // Right MENU key
KEY_PLUS = 0xBB, // Plus Key (+) KEY_OEM_1 = 0xBA, // for US ";:"
KEY_COMMA = 0xBC, // Comma Key (,) KEY_PLUS = 0xBB, // Plus Key "+"
KEY_MINUS = 0xBD, // Minus Key (-) KEY_COMMA = 0xBC, // Comma Key ","
KEY_PERIOD = 0xBE, // Period Key (.) KEY_MINUS = 0xBD, // Minus Key "-"
KEY_PERIOD = 0xBE, // Period Key "."
KEY_OEM_2 = 0xBF, // for US "/?"
KEY_OEM_3 = 0xC0, // for US "`~"
KEY_OEM_4 = 0xDB, // for US "[{"
KEY_OEM_5 = 0xDC, // for US "\|"
KEY_OEM_6 = 0xDD, // for US "]}"
KEY_OEM_7 = 0xDE, // for US "'""
KEY_OEM_8 = 0xDF, // None
KEY_OEM_AX = 0xE1, // for Japan "AX"
KEY_OEM_102 = 0xE2, // "<>" or "\|"
KEY_ATTN = 0xF6, // Attn key KEY_ATTN = 0xF6, // Attn key
KEY_CRSEL = 0xF7, // CrSel key KEY_CRSEL = 0xF7, // CrSel key
KEY_EXSEL = 0xF8, // ExSel key KEY_EXSEL = 0xF8, // ExSel key
......
...@@ -82,10 +82,27 @@ namespace core ...@@ -82,10 +82,27 @@ namespace core
} }
//! Check if a point is inside the triangle (border-points count also as inside) //! Check if a point is inside the triangle (border-points count also as inside)
/** \param p Point to test. Assumes that this point is already /** NOTE: When working with T='int' you should prefer isPointInsideFast, as
isPointInside will run into number-overflows already with coordinates in the 3-digit-range.
\param p Point to test. Assumes that this point is already
on the plane of the triangle. on the plane of the triangle.
\return True if the point is inside the triangle, otherwise false. */ \return True if the point is inside the triangle, otherwise false. */
bool isPointInside(const vector3d<T>& p) const bool isPointInside(const vector3d<T>& p) const
{
return (isOnSameSide(p, pointA, pointB, pointC) &&
isOnSameSide(p, pointB, pointA, pointC) &&
isOnSameSide(p, pointC, pointA, pointB));
}
//! Check if a point is inside the triangle (border-points count also as inside)
/** This method uses a barycentric coordinate system.
It is faster than isPointInside but is more susceptible to floating point rounding
errors. This will especially be noticable when the FPU is in single precision mode
(which is for example set on default by Direct3D).
\param p Point to test. Assumes that this point is already
on the plane of the triangle.
\return True if point is inside the triangle, otherwise false. */
bool isPointInsideFast(const vector3d<T>& p) const
{ {
const vector3d<T> a = pointC - pointA; const vector3d<T> a = pointC - pointA;
const vector3d<T> b = pointB - pointA; const vector3d<T> b = pointB - pointA;
...@@ -105,38 +122,7 @@ namespace core ...@@ -105,38 +122,7 @@ namespace core
// We count border-points as inside to keep downward compatibility. // We count border-points as inside to keep downward compatibility.
// That's why we use >= and <= instead of > and < as more commonly seen on the web. // That's why we use >= and <= instead of > and < as more commonly seen on the web.
return (u >= 0) && (v >= 0) && (u + v <= 1); return (u >= 0) && (v >= 0) && (u + v <= 1);
}
//! 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.
This was once faster than an old isPointInside implementation, but the
current isPointInside is usualy as fast, sometimes even faster.
Border-points in isPointInsideFast are not defined, some are inside and some outside.
\param p Point to test. Assumes that this point is already
on the plane of the triangle.
\return True if point is inside the triangle, otherwise false. */
bool isPointInsideFast(const vector3d<T>& p) const
{
const vector3d<T> f = pointB - pointA;
const vector3d<T> g = pointC - pointA;
const f32 a = f.dotProduct(f);
const f32 b = f.dotProduct(g);
const f32 c = g.dotProduct(g);
const vector3d<T> vp = p - pointA;
const f32 d = vp.dotProduct(f);
const 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 sign(z) && !(sign(x)||sign(y))
return (( (IR(z)) & ~((IR(x))|(IR(y))) ) & 0x80000000)!=0;
} }
......
...@@ -170,7 +170,7 @@ public: ...@@ -170,7 +170,7 @@ public:
vector2d<T>& normalize() vector2d<T>& normalize()
{ {
f32 length = (f32)(X*X + Y*Y); f32 length = (f32)(X*X + Y*Y);
if (core::equals(length, 0.f)) if ( length == 0 )
return *this; return *this;
length = core::reciprocal_squareroot ( length ); length = core::reciprocal_squareroot ( length );
X = (T)(X * length); X = (T)(X * length);
......
...@@ -168,7 +168,7 @@ namespace core ...@@ -168,7 +168,7 @@ namespace core
vector3d<T>& normalize() vector3d<T>& normalize()
{ {
f64 length = X*X + Y*Y + Z*Z; f64 length = X*X + Y*Y + Z*Z;
if (core::equals(length, 0.0)) // this check isn't an optimization but prevents getting NAN in the sqrt. if (length == 0 ) // this check isn't an optimization but prevents getting NAN in the sqrt.
return *this; return *this;
length = core::reciprocal_squareroot(length); length = core::reciprocal_squareroot(length);
......
...@@ -94,9 +94,10 @@ The Irrlicht Engine SDK version 1.8 ...@@ -94,9 +94,10 @@ The Irrlicht Engine SDK version 1.8
* Linux: * Linux:
* Needed: XServer with include files * Needed: XServer with include files
* Optional: OpenGL headers and libraries (libGL.so), for OpenGL support * Optional: OpenGL headers and libraries (libGL.so) for OpenGL support
* GLX + XF86VidMode or XRandr extension (X11 support libraries, GLX +
the latter two for fullscreen mode) XF86VidMode [package x11proto-xf86vidmode-dev] or XRandr
(X11 support libraries, the latter two for fullscreen mode)
* OSX: * OSX:
* Needed: XCode and Cocoa framework * Needed: XCode and Cocoa framework
......
This diff is collapsed.
This diff is collapsed.
...@@ -458,7 +458,7 @@ bool CIrrDeviceSDL::run() ...@@ -458,7 +458,7 @@ bool CIrrDeviceSDL::run()
#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) #if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
// TODO: Check if the multiple open/close calls are too expensive, then // TODO: Check if the multiple open/close calls are too expensive, then
// open/close in the constructor/destructor instead // open/close in the constructor/destructor instead
// update joystick states manually // update joystick states manually
SDL_JoystickUpdate(); SDL_JoystickUpdate();
...@@ -478,7 +478,7 @@ bool CIrrDeviceSDL::run() ...@@ -478,7 +478,7 @@ bool CIrrDeviceSDL::run()
joyevent.JoystickEvent.ButtonStates |= (SDL_JoystickGetButton(joystick, j)<<j); joyevent.JoystickEvent.ButtonStates |= (SDL_JoystickGetButton(joystick, j)<<j);
// query all axes, already in correct range // query all axes, already in correct range
const int numAxes = core::min_(SDL_JoystickNumAxes(joystick), 6); const int numAxes = core::min_(SDL_JoystickNumAxes(joystick), SEvent::SJoystickEvent::NUMBER_OF_AXES);
joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_X]=0; joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_X]=0;
joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Y]=0; joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Y]=0;
joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Z]=0; joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Z]=0;
...@@ -570,8 +570,8 @@ bool CIrrDeviceSDL::activateJoysticks(core::array<SJoystickInfo> & joystickInfo) ...@@ -570,8 +570,8 @@ bool CIrrDeviceSDL::activateJoysticks(core::array<SJoystickInfo> & joystickInfo)
{ {
char logString[256]; char logString[256];
(void)sprintf(logString, "Found joystick %d, %d axes, %d buttons '%s'", (void)sprintf(logString, "Found joystick %d, %d axes, %d buttons '%s'",
joystick, joystickInfo[joystick].Axes, joystick, joystickInfo[joystick].Axes,
joystickInfo[joystick].Buttons, joystickInfo[joystick].Name.c_str()); joystickInfo[joystick].Buttons, joystickInfo[joystick].Name.c_str());
os::Printer::log(logString, ELL_INFORMATION); os::Printer::log(logString, ELL_INFORMATION);
} }
......
This diff is collapsed.
...@@ -68,8 +68,7 @@ int main(int argumentCount, char * arguments[]) ...@@ -68,8 +68,7 @@ int main(int argumentCount, char * arguments[])
TEST(testS3DVertex); TEST(testS3DVertex);
TEST(testaabbox3d); TEST(testaabbox3d);
TEST(color); TEST(color);
// TODO: Needs to be fixed first TEST(testTriangle3d);
// TEST(testTriangle3d);
TEST(vectorPositionDimension2d); TEST(vectorPositionDimension2d);
// file system checks (with null driver) // file system checks (with null driver)
TEST(filesystem); TEST(filesystem);
......
...@@ -431,6 +431,10 @@ ...@@ -431,6 +431,10 @@
RelativePath=".\triangleSelector.cpp" RelativePath=".\triangleSelector.cpp"
> >
</File> </File>
<File
RelativePath=".\triangle3d.cpp"
>
</File>
<File <File
RelativePath=".\vectorPositionDimension2d.cpp" RelativePath=".\vectorPositionDimension2d.cpp"
> >
......
...@@ -102,7 +102,7 @@ static void stageModifications(int stage, vector3d<T>& point) ...@@ -102,7 +102,7 @@ static void stageModifications(int stage, vector3d<T>& point)
} }
template<class T> template<class T>
static bool isPointInside(triangle3d<T> triangleOrig) static bool isPointInside(triangle3d<T> triangleOrig, bool testIsInside, bool testIsInsideFast)
{ {
bool allExpected=true; bool allExpected=true;
...@@ -124,18 +124,24 @@ static bool isPointInside(triangle3d<T> triangleOrig) ...@@ -124,18 +124,24 @@ static bool isPointInside(triangle3d<T> triangleOrig)
vector3d<T> point = pointsInside[i]; vector3d<T> point = pointsInside[i];
stageModifications(stage, point); stageModifications(stage, point);
allExpected &= triangle.isPointInside( point ); if ( testIsInside )
if ( !allExpected )
{ {
logTestString("triangle3d::isPointInside pointsInside test failed in stage %d point %d\n", stage, i); allExpected &= triangle.isPointInside( point );
return false; if ( !allExpected )
{
logTestString("triangle3d::isPointInside pointsInside test failed in stage %d point %d\n", stage, i);
return false;
}
} }
allExpected &= triangle.isPointInsideFast( point ); if ( testIsInsideFast )
if ( !allExpected )
{ {
logTestString("triangle3d::isPointInsideFast pointsInside test failed in stage %d point %d\n", stage, i); allExpected &= triangle.isPointInsideFast( point );
return false; if ( !allExpected )
{
logTestString("triangle3d::isPointInsideFast pointsInside test failed in stage %d point %d\n", stage, i);
return false;
}
} }
} }
} }
...@@ -163,18 +169,24 @@ static bool isPointInside(triangle3d<T> triangleOrig) ...@@ -163,18 +169,24 @@ static bool isPointInside(triangle3d<T> triangleOrig)
vector3d<T> point = pointsOutside[i]; vector3d<T> point = pointsOutside[i];
stageModifications(stage, point); stageModifications(stage, point);
allExpected &= !triangle.isPointInside( point ); if ( testIsInside )
if ( !allExpected )
{ {
logTestString("triangle3d::isPointInside pointsOutside test failed in stage %d point %d\n", stage, i); allExpected &= !triangle.isPointInside( point );
return false; if ( !allExpected )
{
logTestString("triangle3d::isPointInside pointsOutside test failed in stage %d point %d\n", stage, i);
return false;
}
} }
allExpected &= !triangle.isPointInsideFast( point ); if ( testIsInsideFast )
if ( !allExpected )
{ {
logTestString("triangle3d::isPointInsideFast pointsOutside test failed in stage %d point %d\n", stage, i); allExpected &= !triangle.isPointInsideFast( point );
return false; if ( !allExpected )
{
logTestString("triangle3d::isPointInsideFast pointsOutside test failed in stage %d point %d\n", stage, i);
return false;
}
} }
} }
} }
...@@ -198,25 +210,67 @@ static bool isPointInside(triangle3d<T> triangleOrig) ...@@ -198,25 +210,67 @@ static bool isPointInside(triangle3d<T> triangleOrig)
vector3d<T> point = pointsBorder[i]; vector3d<T> point = pointsBorder[i];
stageModifications(stage, point); stageModifications(stage, point);
allExpected &= triangle.isPointInside( point ); if ( testIsInside )
if ( !allExpected )
{ {
logTestString("triangle3d::isPointInside pointsBorder test failed in stage %d point %d\n", stage, i); allExpected &= triangle.isPointInside( point );
return false; if ( !allExpected )
{
logTestString("triangle3d::isPointInside pointsBorder test failed in stage %d point %d\n", stage, i);
return false;
}
} }
/* results for isPointInsideFast are mixed for border cases, but I guess that's fine. if ( testIsInsideFast )
if ( triangle.isPointInsideFast( point ) ) {
logTestString("+ triangle3d::isPointInsideFast pointsBorder stage %d point %d is INSIDE\n", stage, i); allExpected &= triangle.isPointInsideFast( point );
else if ( !allExpected )
logTestString("- triangle3d::isPointInsideFast pointsBorder stage %d point %d is NOT inside\n", stage, i); {
*/ logTestString("triangle3d::isPointInsideFast pointsBorder test failed in stage %d point %d\n", stage, i);
return false;
}
}
} }
} }
return allExpected; return allExpected;
} }
// Checking behaviour when FPU is set to single precision mode.
// This is somewhat important as Direct3D does by default set the FPU into that mode.
static bool isPointInsideWithSinglePrecision()
{
#ifdef _MSC_VER
int original = _control87( 0, 0 );
_control87(_PC_24, MCW_PC); // single precision (double precision would be _PC_53)
// Testcase just some example which popped up wwhic shows the difference between single precision and double precision
irr::core::triangle3d<irr::f64> t;
irr::core::vector3d<irr::f64> point;
t.pointA.X = 3.7237894e+002f;
t.pointA.Y = -1.0025123e+003f;
t.pointA.Z = 0;
t.pointB.X = 2.6698560e+002f;
t.pointB.Y = -9.8957166e+002f;
t.pointB.Z = 0;
t.pointC.X = 2.6981503e+002f;
t.pointC.Y = -9.3992731e+002f;
t.pointC.Z = 0;
point.X = 2.6981500e+002f;
point.Y = -9.3992743e+002f;
point.Z = 0;
bool ok = !t.isPointInside( point );
_control87(original, 0xfffff); // restore
return ok;
#else
// TODO: Be free to try changing the fpu for other systems.
// I think for MinGW it's still easy, but for Linux this probably also needs changed linker flags.
return true;
#endif
}
// Test the functionality of triangle3d<T> // Test the functionality of triangle3d<T>
/** Validation is done with asserts() against expected results. */ /** Validation is done with asserts() against expected results. */
...@@ -224,6 +278,9 @@ bool testTriangle3d(void) ...@@ -224,6 +278,9 @@ bool testTriangle3d(void)
{ {
bool allExpected = true; bool allExpected = true;
/* TODO: disabled for now. I (aka CuteAlien) have by now an example which allows debugging
that problem easier and also found some workaround (which needs an interface change
and a behaviour change and won't get into 1.7 therefore).
logTestString("Test getIntersectionWithLine with f32\n"); logTestString("Test getIntersectionWithLine with f32\n");
{ {
triangle3df triangle( triangle3df triangle(
...@@ -246,28 +303,38 @@ bool testTriangle3d(void) ...@@ -246,28 +303,38 @@ bool testTriangle3d(void)
ray.end = vector3d<f64>(11250.000000, -1000.000000, 250.000000); ray.end = vector3d<f64>(11250.000000, -1000.000000, 250.000000);
allExpected &= testGetIntersectionWithLine(triangle, ray); allExpected &= testGetIntersectionWithLine(triangle, ray);
} }
*/
/* For now we have no solution yet to fix isPointInside for large integers without
getting worse floating-point precision at the same time.
So instead isPointInsideFast got fixed and should be used for int's.
bool testEigen = triangle3di(vector3di(250, 0, 0), vector3di(0, 0, 500), vector3di(500, 0, 500)).isPointInside(vector3di(300,0,300)); bool testEigen = triangle3di(vector3di(250, 0, 0), vector3di(0, 0, 500), vector3di(500, 0, 500)).isPointInside(vector3di(300,0,300));
if ( !testEigen ) // test from Eigen from here: http://irrlicht.sourceforge.net/forum/viewtopic.php?f=7&t=44372&p=254331#p254331 if ( !testEigen ) // test from Eigen from here: http://irrlicht.sourceforge.net/forum/viewtopic.php?f=7&t=44372&p=254331#p254331
logTestString("Test isPointInside fails with integers\n"); logTestString("Test isPointInside fails with integers\n");
allExpected &= testEigen; allExpected &= testEigen;
*/
logTestString("Test isPointInside with f32\n"); logTestString("Test isPointInside with f32\n");
{ {
triangle3d<f32> t(vector3d<f32>(-1000,-1000,0), vector3d<f32>(1000,-1000,0), vector3d<f32>(0,1000,0)); triangle3d<f32> t(vector3d<f32>(-1000,-1000,0), vector3d<f32>(1000,-1000,0), vector3d<f32>(0,1000,0));
allExpected &= isPointInside(t); allExpected &= isPointInside(t, true, true);
} }
logTestString("Test isPointInside with f64\n"); logTestString("Test isPointInside with f64\n");
{ {
triangle3d<f64> t(vector3d<f64>(-1000,-1000,0), vector3d<f64>(1000,-1000,0), vector3d<f64>(0,1000,0)); triangle3d<f64> t(vector3d<f64>(-1000,-1000,0), vector3d<f64>(1000,-1000,0), vector3d<f64>(0,1000,0));
allExpected &= isPointInside(t); allExpected &= isPointInside(t, true, true);
} }
logTestString("Test isPointInside with s32\n"); logTestString("Test isPointInside with s32\n");
{ {
triangle3d<s32> t(vector3d<s32>(-1000,-1000,0), vector3d<s32>(1000,-1000,0), vector3d<s32>(0,1000,0)); triangle3d<s32> t(vector3d<s32>(-1000,-1000,0), vector3d<s32>(1000,-1000,0), vector3d<s32>(0,1000,0));
allExpected &= isPointInside(t); allExpected &= isPointInside(t, false, true);
}
logTestString("Test isPointInsideWithSinglePrecision\n");
{
allExpected &= isPointInsideWithSinglePrecision();
} }
if(allExpected) if(allExpected)
......
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