diff --git a/changes.txt b/changes.txt index 1ea822aa..0fb39a19 100644 --- a/changes.txt +++ b/changes.txt @@ -9,6 +9,19 @@ Changes in ogl-es (not yet released - will be merged with trunk at some point) -------------------------- Changes in 1.9 (not yet released) +- Bugfix: CMatrix4::transformPlane was calculating the wrong plane-normal before. +- SViewFrustum::recalculateBoundingBox no longer includes camera position in the bounding-box. Only using frustum corners now. Thx @DevSH for bugreport & patch. +- Camera uses now OGL projection matrices with OpenGL driver. Fixes wrong near-plane values with OpenGL (showed too much before). +- Add a flag to most CMatrix4::buildProjectionMatrix functions to allow creating OpenGL projection matrices (target range of -w to w instead of 0 to w). +- Bugfix: CCameraSceneNode resets the IsOrthogonal flag to false now when it recalculates a projection matrix. +- SViewFrustum::setFrom and SViewFrustum constructor now use a parameter to allow to set the correct near clipping plane when the projection matrix doesn't use a target depth range of 0 to z, but for example -z to z. So OGL projections matrices can now also use it. +- Remove code to read boundingbox element in Collada reader as it's not in Collada specification. +- .dae/Collade reader now converts from Collada's right-handed to Irrlicht's left handed coordinate system (switching z to -z) +- Add irr::string::eraseTrailingFloatZeros to kick out trailing 0's for strings generated from floats. +- .dae/Collada writer now converts from Irrlicht's left-handed to Collada's right-handed coordinate system (switching z to -z) +- Switch Collada writer to utf8 xml's. +- Add IXMLWriterUTF8 +- IColladaMeshWriter::writeScene got an additional flag to decide if root should be written. - _IRR_MATERIAL_MAX_TEXTURES_ now set to 8 by default. So we can use now 8 textures per material without recompiling the engine. Additionally there's a new global variable irr::video::MATERIAL_MAX_TEXTURES_USED which can be set to lower numbers to avoid most of the costs coming with this for people not needing more textures. But using more textures via _IRR_MATERIAL_MAX_TEXTURES_ also has become less calculation intensive than it was in the past, so in release builds the difference is hardly noticeable. diff --git a/include/IAttributes.h b/include/IAttributes.h index 90dce63a..507561d8 100644 --- a/include/IAttributes.h +++ b/include/IAttributes.h @@ -24,6 +24,7 @@ #include "irrString.h" #include "irrArray.h" #include "IXMLReader.h" +#include "IXMLWriter.h" #include "EAttributes.h" #include "path.h" @@ -35,7 +36,6 @@ namespace video } // end namespace video namespace io { - class IXMLWriter; //! Provides a generic interface for attributes and their values and the possibility to serialize them class IAttributes : public virtual IReferenceCounted diff --git a/include/IColladaMeshWriter.h b/include/IColladaMeshWriter.h index 8a9f779c..cbd4030e 100644 --- a/include/IColladaMeshWriter.h +++ b/include/IColladaMeshWriter.h @@ -171,7 +171,7 @@ namespace scene \param instance When E_COLLADA_GEOMETRY_WRITING is not ECGI_PER_MESH then several instances of the same mesh can be written and this counts them. */ - virtual irr::core::stringw nameForMesh(const scene::IMesh* mesh, int instance) = 0; + virtual irr::core::stringc nameForMesh(const scene::IMesh* mesh, int instance) = 0; //! Return a unique name for the given node /** Note that names really must be unique here per node-pointer, so @@ -180,7 +180,7 @@ namespace scene the xs::NCName standard to be valid, you can run them through IColladaMeshWriter::toNCName to ensure that. */ - virtual irr::core::stringw nameForNode(const scene::ISceneNode* node) = 0; + virtual irr::core::stringc nameForNode(const scene::ISceneNode* node) = 0; //! Return a name for the material /** There is one material created in the writer for each unique name. @@ -193,7 +193,7 @@ namespace scene Names must follow the xs::NCName standard to be valid, you can run them through IColladaMeshWriter::toNCName to ensure that. */ - virtual irr::core::stringw nameForMaterial(const video::SMaterial & material, int materialId, const scene::IMesh* mesh, const scene::ISceneNode* node) = 0; + virtual irr::core::stringc nameForMaterial(const video::SMaterial & material, int materialId, const scene::IMesh* mesh, const scene::ISceneNode* node) = 0; }; @@ -206,8 +206,11 @@ namespace scene : Properties(0), DefaultProperties(0), NameGenerator(0), DefaultNameGenerator(0) , WriteTextures(true), WriteDefaultScene(true), ExportSMaterialOnce(true) , AmbientLight(0.f, 0.f, 0.f, 1.f) + , UnitMeter(1.f), UnitName("meter") , GeometryWriting(ECGI_PER_MESH) { + ParamNamesUV[0] = "U"; + ParamNamesUV[1] = "V"; } //! Destructor @@ -224,7 +227,8 @@ namespace scene } //! writes a scene starting with the given node - virtual bool writeScene(io::IWriteFile* file, scene::ISceneNode* root) = 0; + //\param writeRoot: 0 = no, 1=yes unless root is scenemanager, 2=yes + virtual bool writeScene(io::IWriteFile* file, scene::ISceneNode* root, int writeRoot=1) = 0; //! Set if texture information should be written @@ -267,6 +271,28 @@ namespace scene return AmbientLight; } + //! Set the unit distances for all elements and objects + /** + \param meter: Real-world meters to use per unit. Default 1 unit = 1 meter. For 1 unit = 1cm you would set to 0.01 + \param name: Name to use for distance unit. Default is "meter". */ + virtual void setUnit(irr::f32 meter, const irr::core::stringc& name) + { + UnitMeter = meter; + UnitName = name; + } + + //! Return real world meters to use per unit for all elements and objects + virtual irr::f32 getUnitMeter() const + { + return UnitMeter; + } + + //! Return name to use for distance units. Like p.E. "meter". + virtual irr::core::stringc getUnitName() const + { + return UnitName; + } + //! Control when and how often a mesh is written /** Optimally ECGI_PER_MESH would be always sufficient - writing geometry once per mesh. Unfortunately many tools (at the time of writing this nearly all of them) have trouble @@ -358,13 +384,26 @@ namespace scene //! Restrict the characters of oldString a set of allowed characters in xs::NCName and add the prefix. /** A tool function to help when using a custom name generator to generative valid names for collada names and id's. */ - virtual irr::core::stringw toNCName(const irr::core::stringw& oldString, const irr::core::stringw& prefix=irr::core::stringw(L"_NC_")) const = 0; + virtual irr::core::stringc toNCName(const irr::core::stringc& oldString, const irr::core::stringc& prefix=irr::core::stringc("_NC_")) const = 0; //! After export you can find out which name had been used for writing the geometry for this node. /** The name comes from IColladaMeshWriterNames::nameForMesh, but you can't access the node there. \return Either a pointer to the name or NULL */ // TODO: Function is not const because there is no const getMesh() function for several Irrlicht nodes. - virtual const irr::core::stringw* findGeometryNameForNode(ISceneNode* node) = 0; + virtual const irr::core::stringc* findGeometryNameForNode(ISceneNode* node) = 0; + + //! Change param name used for UV's. + /** Param names for UV's have a name. By default it's "U" and "V". + Usually it doesn't matter as names are optional in Collada anyway. + But unfortunately some tools insist on specific names. + So if "U", "V" does not work then try to export by setting this to "S", "T". + One tool which insists on "S", "T" is for example SketchUp. + */ + void SetParamNamesUV(const core::stringc& u, const core::stringc& v) + { + ParamNamesUV[0] = u; + ParamNamesUV[1] = v; + } protected: @@ -392,6 +431,9 @@ namespace scene DefaultNameGenerator = p; } + protected: + irr::core::stringc ParamNamesUV[2]; + private: IColladaMeshWriterProperties * Properties; IColladaMeshWriterProperties * DefaultProperties; @@ -401,6 +443,8 @@ namespace scene bool WriteDefaultScene; bool ExportSMaterialOnce; video::SColorf AmbientLight; + irr::f32 UnitMeter; + irr::core::stringc UnitName; E_COLLADA_GEOMETRY_WRITING GeometryWriting; }; diff --git a/include/IFileSystem.h b/include/IFileSystem.h index 48e217ef..f9a6ee61 100644 --- a/include/IFileSystem.h +++ b/include/IFileSystem.h @@ -7,6 +7,7 @@ #include "IReferenceCounted.h" #include "IXMLReader.h" +#include "IXMLWriter.h" #include "IFileArchive.h" namespace irr @@ -21,7 +22,6 @@ namespace io class IReadFile; class IWriteFile; class IFileList; -class IXMLWriter; class IAttributes; @@ -354,6 +354,20 @@ public: See IReferenceCounted::drop() for more information. */ virtual IXMLReaderUTF8* createXMLReaderUTF8(IReadFile* file) =0; + //! Creates a XML Writer from a file which will write ASCII/UTF-8 characters (char*). + /** \return 0, if file could not be opened, otherwise a pointer to the created + IXMLWriter is returned. After use, the reader + has to be deleted using its IXMLWriter::drop() method. + See IReferenceCounted::drop() for more information. */ + virtual IXMLWriterUTF8* createXMLWriterUTF8(const path& filename) =0; + + //! Creates a XML Writer from a file which will write ASCII/UTF-8 characters (char*). + /** \return 0, if file could not be opened, otherwise a pointer to the created + IXMLWriter is returned. After use, the reader + has to be deleted using its IXMLWriter::drop() method. + See IReferenceCounted::drop() for more information. */ + virtual IXMLWriterUTF8* createXMLWriterUTF8(IWriteFile* file) =0; + //! Creates a XML Writer from a file. /** \return 0, if file could not be opened, otherwise a pointer to the created IXMLWriter is returned. After use, the reader diff --git a/include/IGUIEnvironment.h b/include/IGUIEnvironment.h index 0fc2a8ec..f58b80a3 100644 --- a/include/IGUIEnvironment.h +++ b/include/IGUIEnvironment.h @@ -12,6 +12,7 @@ #include "EFocusFlags.h" #include "IEventReceiver.h" #include "IXMLReader.h" +#include "IXMLWriter.h" #include "path.h" namespace irr @@ -21,7 +22,6 @@ namespace irr namespace io { - class IXMLWriter; class IReadFile; class IWriteFile; class IFileSystem; diff --git a/include/ISceneManager.h b/include/ISceneManager.h index 81c5d98c..e9db1ef6 100644 --- a/include/ISceneManager.h +++ b/include/ISceneManager.h @@ -19,6 +19,7 @@ #include "SceneParameters.h" #include "IGeometryCreator.h" #include "ISkinnedMesh.h" +#include "IXMLWriter.h" namespace irr { diff --git a/include/IXMLWriter.h b/include/IXMLWriter.h index a68cac9c..18c40e28 100644 --- a/include/IXMLWriter.h +++ b/include/IXMLWriter.h @@ -6,72 +6,21 @@ #define __I_XML_WRITER_H_INCLUDED__ #include "IReferenceCounted.h" -#include "irrArray.h" -#include "irrString.h" +#include "irrXML.h" namespace irr { namespace io { + //! An xml writer for wide characters, derived from IReferenceCounted. + /** Call IFileSystem::createXMLReader(). to create an IXMLWriter */ + typedef IIrrXMLWriter IXMLWriter; - //! Interface providing methods for making it easier to write XML files. - /** This XML Writer writes xml files using in the platform dependent - wchar_t format and sets the xml-encoding correspondingly. */ - class IXMLWriter : public virtual IReferenceCounted - { - public: - //! Writes an xml 1.0 header. - /** Looks like <?xml version="1.0"?>. This should always - be called before writing anything other, because also the text - file header for Unicode texts is written out with this method. */ - virtual void writeXMLHeader() = 0; - - //! Writes an xml element with maximal 5 attributes like "" or - //! <foo optAttr="value" />. - /** The element can be empty or not. - \param name: Name of the element - \param empty: Specifies if the element should be empty. Like - "". If You set this to false, something like this is - written instead: "". - \param attr1Name: 1st attributes name - \param attr1Value: 1st attributes value - \param attr2Name: 2nd attributes name - \param attr2Value: 2nd attributes value - \param attr3Name: 3rd attributes name - \param attr3Value: 3rd attributes value - \param attr4Name: 4th attributes name - \param attr4Value: 4th attributes value - \param attr5Name: 5th attributes name - \param attr5Value: 5th attributes value */ - virtual void writeElement(const wchar_t* name, bool empty=false, - const wchar_t* attr1Name = 0, const wchar_t* attr1Value = 0, - const wchar_t* attr2Name = 0, const wchar_t* attr2Value = 0, - const wchar_t* attr3Name = 0, const wchar_t* attr3Value = 0, - const wchar_t* attr4Name = 0, const wchar_t* attr4Value = 0, - const wchar_t* attr5Name = 0, const wchar_t* attr5Value = 0) = 0; - - //! Writes an xml element with any number of attributes - virtual void writeElement(const wchar_t* name, bool empty, - core::array &names, core::array &values) = 0; - - //! Writes a comment into the xml file - virtual void writeComment(const wchar_t* comment) = 0; - - //! Writes the closing tag for an element. Like "" - virtual void writeClosingTag(const wchar_t* name) = 0; - - //! Writes a text into the file. - /** All occurrences of special characters such as - & (&), < (<), > (>), and " (") are automatically - replaced. */ - virtual void writeText(const wchar_t* text) = 0; - - //! Writes a line break - virtual void writeLineBreak() = 0; - }; + //! An xml writer for ASCII or UTF-8 characters, derived from IReferenceCounted. + /** Call IFileSystem::createXMLReaderUtf8(). to create an IXMLWriter */ + typedef IIrrXMLWriter IXMLWriterUTF8; } // end namespace io } // end namespace irr #endif - diff --git a/include/SViewFrustum.h b/include/SViewFrustum.h index ee7db2b3..b1d53e39 100644 --- a/include/SViewFrustum.h +++ b/include/SViewFrustum.h @@ -51,10 +51,12 @@ namespace scene SViewFrustum(const SViewFrustum& other); //! This constructor creates a view frustum based on a projection and/or view matrix. - SViewFrustum(const core::matrix4& mat); + //\param zClipFromZero: Clipping of z can be projected from 0 to w when true (D3D style) and from -w to w when false (OGL style). + SViewFrustum(const core::matrix4& mat, bool zClipFromZero); //! This constructor creates a view frustum based on a projection and/or view matrix. - inline void setFrom(const core::matrix4& mat); + //\param zClipFromZero: Clipping of z can be projected from 0 to w when true (D3D style) and from -w to w when false (OGL style). + inline void setFrom(const core::matrix4& mat, bool zClipFromZero); //! transforms the frustum by the matrix /** \param mat: Matrix by which the view frustum is transformed.*/ @@ -159,9 +161,9 @@ namespace scene BoundingCenter = other.BoundingCenter; } - inline SViewFrustum::SViewFrustum(const core::matrix4& mat) + inline SViewFrustum::SViewFrustum(const core::matrix4& mat, bool zClipFromZero) { - setFrom(mat); + setFrom(mat, zClipFromZero); } @@ -262,12 +264,14 @@ namespace scene inline void SViewFrustum::recalculateBoundingBox() { - boundingBox.reset ( cameraPosition ); - - boundingBox.addInternalPoint(getFarLeftUp()); + boundingBox.reset(getNearLeftUp()); + boundingBox.addInternalPoint(getNearRightUp()); + boundingBox.addInternalPoint(getNearLeftDown()); + boundingBox.addInternalPoint(getNearRightDown()); boundingBox.addInternalPoint(getFarRightUp()); boundingBox.addInternalPoint(getFarLeftDown()); boundingBox.addInternalPoint(getFarRightDown()); + boundingBox.addInternalPoint(getFarLeftUp()); // Also recalculate the bounding sphere when the bbox changes recalculateBoundingSphere(); @@ -290,7 +294,7 @@ namespace scene //! This constructor creates a view frustum based on a projection //! and/or view matrix. - inline void SViewFrustum::setFrom(const core::matrix4& mat) + inline void SViewFrustum::setFrom(const core::matrix4& mat, bool zClipFromZero) { // left clipping plane planes[VF_LEFT_PLANE].Normal.X = mat[3 ] + mat[0]; @@ -323,10 +327,21 @@ namespace scene planes[VF_FAR_PLANE].D = mat[15] - mat[14]; // near clipping plane - planes[VF_NEAR_PLANE].Normal.X = mat[2]; - planes[VF_NEAR_PLANE].Normal.Y = mat[6]; - planes[VF_NEAR_PLANE].Normal.Z = mat[10]; - planes[VF_NEAR_PLANE].D = mat[14]; + if ( zClipFromZero ) + { + planes[VF_NEAR_PLANE].Normal.X = mat[2]; + planes[VF_NEAR_PLANE].Normal.Y = mat[6]; + planes[VF_NEAR_PLANE].Normal.Z = mat[10]; + planes[VF_NEAR_PLANE].D = mat[14]; + } + else + { + // near clipping plane + planes[VF_NEAR_PLANE].Normal.X = mat[3 ] + mat[2]; + planes[VF_NEAR_PLANE].Normal.Y = mat[7 ] + mat[6]; + planes[VF_NEAR_PLANE].Normal.Z = mat[11] + mat[10]; + planes[VF_NEAR_PLANE].D = mat[15] + mat[14]; + } // normalize normals u32 i; diff --git a/include/coreutil.h b/include/coreutil.h index 072a6b3a..b042a5b4 100644 --- a/include/coreutil.h +++ b/include/coreutil.h @@ -175,7 +175,7 @@ static inline void splitFilename(const io::path &name, io::path* path=0, static inline io::path mergeFilename(const io::path& path, const io::path& filename, const io::path& extension = "") { io::path result(path); - + if ( !result.empty() ) { fschar_t last = result.lastChar(); @@ -190,15 +190,12 @@ static inline io::path mergeFilename(const io::path& path, const io::path& filen result += _IRR_TEXT('.'); result += extension; } - + return result; } //! some standard function ( to remove dependencies ) -#undef isdigit -#undef isspace -#undef isupper inline s32 isdigit(s32 c) { return c >= '0' && c <= '9'; } inline s32 isspace(s32 c) { return c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v'; } inline s32 isupper(s32 c) { return c >= 'A' && c <= 'Z'; } diff --git a/include/irrString.h b/include/irrString.h index abf92370..2643c975 100644 --- a/include/irrString.h +++ b/include/irrString.h @@ -36,6 +36,7 @@ outside the string class for explicit use. template > class string; static size_t multibyteToWString(string& destination, const char* source, u32 sourceSize); +inline s32 isdigit(s32 c); enum eLocaleID { @@ -1244,7 +1245,7 @@ public: //! Trims the string. /** Removes the specified characters (by default, Latin-1 whitespace) - from the begining and the end of the string. */ + from the beginning and the end of the string. */ string& trim(const string & whitespace = " \t\n\r") { // find start and end of the substring without the specified characters @@ -1257,6 +1258,41 @@ public: return (*this = subString(begin, (end +1) - begin)); } + //! Erase 0's at the end when a string ends with a floating point number + /** After generating strings from floats we often end up with strings + ending up with lots of zeros which don't add any value. Erase 'em all. + Examples: "0.100000" becomes "0.1" + "10.000000" becomes "10" + "foo 3.140000" becomes "foo 3.14" + "no_num.000" stays "no_num.000" + "1." stays "1." + */ + string& eraseTrailingFloatZeros(char decimalPoint='.') + { + s32 i=findLastCharNotInList("0", 1); + if ( i > 0 && (u32)i < used-2 ) // non 0 must be found and not last char (also used is at least 2 when i > 0) + { + u32 eraseStart=i+1; + u32 dot=0; + if( core::isdigit(array[i]) ) + { + while( --i>0 && core::isdigit(array[i]) ); + if ( array[i] == decimalPoint ) + dot = i; + } + else if ( array[i] == decimalPoint ) + { + dot = i; + eraseStart = i; + } + if ( dot > 0 && core::isdigit(array[dot-1]) ) + { + array[eraseStart] = 0; + used = eraseStart+1; + } + } + return *this; + } //! Erases a character from the string. /** May be slow, because all elements @@ -1331,7 +1367,7 @@ public: return 0; const u32 oldSize=ret.size(); - + u32 tokenStartIdx = 0; for (u32 i=0; i()); } - tokenStartIdx = i+1; + tokenStartIdx = i+1; break; } } } if ((used - 1) > tokenStartIdx) ret.push_back(string(&array[tokenStartIdx], (used - 1) - tokenStartIdx)); - + return ret.size()-oldSize; } diff --git a/include/irrXML.h b/include/irrXML.h index 5957e086..57c3b549 100644 --- a/include/irrXML.h +++ b/include/irrXML.h @@ -7,6 +7,8 @@ #include #include "IrrCompileConfig.h" +#include "irrArray.h" +#include "irrString.h" /** \mainpage irrXML 1.2 API documentation
@@ -370,6 +372,65 @@ namespace io virtual ETEXT_FORMAT getParserFormat() const = 0; }; + //! Interface providing methods for making it easier to write XML files. + template + class IIrrXMLWriter : public super_class + { + public: + + //! Destructor + virtual ~IIrrXMLWriter() {} + + //! Writes an xml 1.0 header. + /** Looks like <?xml version="1.0"?>. This should always + be called before writing anything other, because also the text + file header for Unicode texts is written out with this method. */ + virtual void writeXMLHeader() = 0; + + //! Writes an xml element with maximal 5 attributes like "" or + //! <foo optAttr="value" />. + /** The element can be empty or not. + \param name: Name of the element + \param empty: Specifies if the element should be empty. Like + "". If You set this to false, something like this is + written instead: "". + \param attr1Name: 1st attributes name + \param attr1Value: 1st attributes value + \param attr2Name: 2nd attributes name + \param attr2Value: 2nd attributes value + \param attr3Name: 3rd attributes name + \param attr3Value: 3rd attributes value + \param attr4Name: 4th attributes name + \param attr4Value: 4th attributes value + \param attr5Name: 5th attributes name + \param attr5Value: 5th attributes value */ + virtual void writeElement(const char_type* name, bool empty=false, + const char_type* attr1Name = 0, const char_type* attr1Value = 0, + const char_type* attr2Name = 0, const char_type* attr2Value = 0, + const char_type* attr3Name = 0, const char_type* attr3Value = 0, + const char_type* attr4Name = 0, const char_type* attr4Value = 0, + const char_type* attr5Name = 0, const char_type* attr5Value = 0) = 0; + + //! Writes an xml element with any number of attributes + virtual void writeElement(const char_type* name, bool empty, + core::array > &names, core::array > &values) = 0; + + //! Writes a comment into the xml file + virtual void writeComment(const char_type* comment) = 0; + + //! Writes the closing tag for an element. Like "" + virtual void writeClosingTag(const char_type* name) = 0; + + //! Writes a text into the file. + /** All occurrences of special characters such as + & (&), < (<), > (>), and " (") are automatically + replaced. */ + virtual void writeText(const char_type* text) = 0; + + //! Writes a line break + virtual void writeLineBreak() = 0; + }; + template struct xmlChar diff --git a/include/matrix4.h b/include/matrix4.h index e41f7858..615e77ad 100644 --- a/include/matrix4.h +++ b/include/matrix4.h @@ -289,25 +289,27 @@ namespace core bool getInverse(CMatrix4& out) const; //! Builds a right-handed perspective projection matrix based on a field of view - CMatrix4& buildProjectionMatrixPerspectiveFovRH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar); + //\param zClipFromZero: Clipping of z can be projected from 0 to w when true (D3D style) and from -w to w when false (OGL style). + CMatrix4& buildProjectionMatrixPerspectiveFovRH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar, bool zClipFromZero=true); //! Builds a left-handed perspective projection matrix based on a field of view - CMatrix4& buildProjectionMatrixPerspectiveFovLH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar); + CMatrix4& buildProjectionMatrixPerspectiveFovLH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar, bool zClipFromZero=true); //! Builds a left-handed perspective projection matrix based on a field of view, with far plane at infinity CMatrix4& buildProjectionMatrixPerspectiveFovInfinityLH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 epsilon=0); //! Builds a right-handed perspective projection matrix. - CMatrix4& buildProjectionMatrixPerspectiveRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar); + CMatrix4& buildProjectionMatrixPerspectiveRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero=true); //! Builds a left-handed perspective projection matrix. - CMatrix4& buildProjectionMatrixPerspectiveLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar); + CMatrix4& buildProjectionMatrixPerspectiveLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero=true); //! Builds a left-handed orthogonal projection matrix. - CMatrix4& buildProjectionMatrixOrthoLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar); + //\param zClipFromZero: Clipping of z can be projected from 0 to 1 when true (D3D style) and from -1 to 1 when false (OGL style). + CMatrix4& buildProjectionMatrixOrthoLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero=true); //! Builds a right-handed orthogonal projection matrix. - CMatrix4& buildProjectionMatrixOrthoRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar); + CMatrix4& buildProjectionMatrixOrthoRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero=true); //! Builds a left-handed look-at matrix. CMatrix4& buildCameraLookAtMatrixLH( @@ -1235,9 +1237,8 @@ namespace core // Transform the normal by the transposed inverse of the matrix CMatrix4 transposedInverse(*this, EM4CONST_INVERSE_TRANSPOSED); vector3df normal = plane.Normal; - transposedInverse.transformVect(normal); - - plane.setPlane(member, normal); + transposedInverse.rotateVect(normal); + plane.setPlane(member, normal.normalize()); } //! Transforms a plane by this matrix @@ -1542,7 +1543,7 @@ namespace core // Builds a right-handed perspective projection matrix based on a field of view template inline CMatrix4& CMatrix4::buildProjectionMatrixPerspectiveFovRH( - f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar) + f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar, bool zClipFromZero) { const f64 h = reciprocal(tan(fieldOfViewRadians*0.5)); _IRR_DEBUG_BREAK_IF(aspectRatio==0.f); //divide by zero @@ -1561,16 +1562,25 @@ namespace core M[8] = 0; M[9] = 0; - M[10] = (T)(zFar/(zNear-zFar)); // DirectX version -// M[10] = (T)(zFar+zNear/(zNear-zFar)); // OpenGL version + //M[10] M[11] = -1; M[12] = 0; M[13] = 0; - M[14] = (T)(zNear*zFar/(zNear-zFar)); // DirectX version -// M[14] = (T)(2.0f*zNear*zFar/(zNear-zFar)); // OpenGL version + //M[14] M[15] = 0; + if ( zClipFromZero ) // DirectX version + { + M[10] = (T)(zFar/(zNear-zFar)); + M[14] = (T)(zNear*zFar/(zNear-zFar)); + } + else // OpenGL version + { + M[10] = (T)((zFar+zNear)/(zNear-zFar)); + M[14] = (T)(2.0f*zNear*zFar/(zNear-zFar)); + } + #if defined ( USE_MATRIX_TEST ) definitelyIdentityMatrix=false; #endif @@ -1581,7 +1591,7 @@ namespace core // Builds a left-handed perspective projection matrix based on a field of view template inline CMatrix4& CMatrix4::buildProjectionMatrixPerspectiveFovLH( - f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar) + f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar, bool zClipFromZero) { const f64 h = reciprocal(tan(fieldOfViewRadians*0.5)); _IRR_DEBUG_BREAK_IF(aspectRatio==0.f); //divide by zero @@ -1600,14 +1610,25 @@ namespace core M[8] = 0; M[9] = 0; - M[10] = (T)(zFar/(zFar-zNear)); + //M[10] M[11] = 1; M[12] = 0; M[13] = 0; - M[14] = (T)(-zNear*zFar/(zFar-zNear)); + //M[14] M[15] = 0; + if ( zClipFromZero ) // DirectX version + { + M[10] = (T)(zFar/(zFar-zNear)); + M[14] = (T)(-zNear*zFar/(zFar-zNear)); + } + else // OpenGL version + { + M[10] = (T)((zFar+zNear)/(zFar-zNear)); + M[14] = (T)(2.0f*zNear*zFar/(zNear-zFar)); + } + #if defined ( USE_MATRIX_TEST ) definitelyIdentityMatrix=false; #endif @@ -1654,7 +1675,7 @@ namespace core // Builds a left-handed orthogonal projection matrix. template inline CMatrix4& CMatrix4::buildProjectionMatrixOrthoLH( - f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar) + f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero) { _IRR_DEBUG_BREAK_IF(widthOfViewVolume==0.f); //divide by zero _IRR_DEBUG_BREAK_IF(heightOfViewVolume==0.f); //divide by zero @@ -1671,14 +1692,25 @@ namespace core M[8] = 0; M[9] = 0; - M[10] = (T)(1/(zFar-zNear)); + // M[10] M[11] = 0; - + M[12] = 0; M[13] = 0; - M[14] = (T)(zNear/(zNear-zFar)); + // M[14] M[15] = 1; + if ( zClipFromZero ) + { + M[10] = (T)(1/(zFar-zNear)); + M[14] = (T)(zNear/(zNear-zFar)); + } + else + { + M[10] = (T)(2/(zFar-zNear)); + M[14] = (T)-(zFar+zNear)/(zFar-zNear); + } + #if defined ( USE_MATRIX_TEST ) definitelyIdentityMatrix=false; #endif @@ -1689,7 +1721,7 @@ namespace core // Builds a right-handed orthogonal projection matrix. template inline CMatrix4& CMatrix4::buildProjectionMatrixOrthoRH( - f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar) + f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero) { _IRR_DEBUG_BREAK_IF(widthOfViewVolume==0.f); //divide by zero _IRR_DEBUG_BREAK_IF(heightOfViewVolume==0.f); //divide by zero @@ -1706,14 +1738,25 @@ namespace core M[8] = 0; M[9] = 0; - M[10] = (T)(1/(zNear-zFar)); + // M[10] M[11] = 0; M[12] = 0; M[13] = 0; - M[14] = (T)(zNear/(zNear-zFar)); + // M[14] M[15] = 1; + if ( zClipFromZero ) + { + M[10] = (T)(1/(zNear-zFar)); + M[14] = (T)(zNear/(zNear-zFar)); + } + else + { + M[10] = (T)(2/(zNear-zFar)); + M[14] = (T)-(zFar+zNear)/(zFar-zNear); + } + #if defined ( USE_MATRIX_TEST ) definitelyIdentityMatrix=false; #endif @@ -1724,7 +1767,7 @@ namespace core // Builds a right-handed perspective projection matrix. template inline CMatrix4& CMatrix4::buildProjectionMatrixPerspectiveRH( - f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar) + f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero) { _IRR_DEBUG_BREAK_IF(widthOfViewVolume==0.f); //divide by zero _IRR_DEBUG_BREAK_IF(heightOfViewVolume==0.f); //divide by zero @@ -1741,14 +1784,25 @@ namespace core M[8] = 0; M[9] = 0; - M[10] = (T)(zFar/(zNear-zFar)); + //M[10] M[11] = -1; M[12] = 0; M[13] = 0; - M[14] = (T)(zNear*zFar/(zNear-zFar)); + //M[14] M[15] = 0; + if ( zClipFromZero ) // DirectX version + { + M[10] = (T)(zFar/(zNear-zFar)); + M[14] = (T)(zNear*zFar/(zNear-zFar)); + } + else // OpenGL version + { + M[10] = (T)((zFar+zNear)/(zNear-zFar)); + M[14] = (T)(2.0f*zNear*zFar/(zNear-zFar)); + } + #if defined ( USE_MATRIX_TEST ) definitelyIdentityMatrix=false; #endif @@ -1759,7 +1813,7 @@ namespace core // Builds a left-handed perspective projection matrix. template inline CMatrix4& CMatrix4::buildProjectionMatrixPerspectiveLH( - f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar) + f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero) { _IRR_DEBUG_BREAK_IF(widthOfViewVolume==0.f); //divide by zero _IRR_DEBUG_BREAK_IF(heightOfViewVolume==0.f); //divide by zero @@ -1776,13 +1830,25 @@ namespace core M[8] = 0; M[9] = 0; - M[10] = (T)(zFar/(zFar-zNear)); + //M[10] M[11] = 1; M[12] = 0; M[13] = 0; - M[14] = (T)(zNear*zFar/(zNear-zFar)); + //M[14] = (T)(zNear*zFar/(zNear-zFar)); M[15] = 0; + + if ( zClipFromZero ) // DirectX version + { + M[10] = (T)(zFar/(zFar-zNear)); + M[14] = (T)(zNear*zFar/(zNear-zFar)); + } + else // OpenGL version + { + M[10] = (T)((zFar+zNear)/(zFar-zNear)); + M[14] = (T)(2.0f*zNear*zFar/(zNear-zFar)); + } + #if defined ( USE_MATRIX_TEST ) definitelyIdentityMatrix=false; #endif diff --git a/include/vector2d.h b/include/vector2d.h index b8eaf70b..b158a033 100644 --- a/include/vector2d.h +++ b/include/vector2d.h @@ -323,7 +323,7 @@ public: (T)(Y * mul0 + v2.Y * mul1 + v3.Y * mul2)); } - /*! Test if this point and another 2 poitns taken as triplet + /*! Test if this point and another 2 points taken as triplet are colinear, clockwise, anticlockwise. This can be used also to check winding order in triangles for 2D meshes. \return 0 if points are colinear, 1 if clockwise, 2 if anticlockwise diff --git a/lib/Linux/readme.txt b/lib/Linux/readme.txt new file mode 100644 index 00000000..40bad90a --- /dev/null +++ b/lib/Linux/readme.txt @@ -0,0 +1,2 @@ +You might have to recompile the engine to get library files in here. +Check the readme.txt in the corresponding bin folders for more information. diff --git a/lib/OSX/readme.txt b/lib/OSX/readme.txt new file mode 100644 index 00000000..40bad90a --- /dev/null +++ b/lib/OSX/readme.txt @@ -0,0 +1,2 @@ +You might have to recompile the engine to get library files in here. +Check the readme.txt in the corresponding bin folders for more information. diff --git a/lib/Win32-gcc/readme.txt b/lib/Win32-gcc/readme.txt new file mode 100644 index 00000000..40bad90a --- /dev/null +++ b/lib/Win32-gcc/readme.txt @@ -0,0 +1,2 @@ +You might have to recompile the engine to get library files in here. +Check the readme.txt in the corresponding bin folders for more information. diff --git a/lib/Win32-visualstudio/readme.txt b/lib/Win32-visualstudio/readme.txt new file mode 100644 index 00000000..40bad90a --- /dev/null +++ b/lib/Win32-visualstudio/readme.txt @@ -0,0 +1,2 @@ +You might have to recompile the engine to get library files in here. +Check the readme.txt in the corresponding bin folders for more information. diff --git a/lib/Win64-visualStudio/readme.txt b/lib/Win64-visualStudio/readme.txt new file mode 100644 index 00000000..40bad90a --- /dev/null +++ b/lib/Win64-visualStudio/readme.txt @@ -0,0 +1,2 @@ +You might have to recompile the engine to get library files in here. +Check the readme.txt in the corresponding bin folders for more information. diff --git a/source/Irrlicht/COGLES2Driver.cpp b/source/Irrlicht/COGLES2Driver.cpp index 9c8008a7..f40eaa93 100644 --- a/source/Irrlicht/COGLES2Driver.cpp +++ b/source/Irrlicht/COGLES2Driver.cpp @@ -2586,9 +2586,7 @@ COGLES2Driver::~COGLES2Driver() void COGLES2Driver::removeTexture(ITexture* texture) { - if (!texture) - return; - + CacheHandler->getTextureCache().remove(texture); CNullDriver::removeTexture(texture); } diff --git a/source/Irrlicht/COGLESDriver.cpp b/source/Irrlicht/COGLESDriver.cpp index 9c2ce704..ed151f7c 100644 --- a/source/Irrlicht/COGLESDriver.cpp +++ b/source/Irrlicht/COGLESDriver.cpp @@ -2929,9 +2929,7 @@ IImage* COGLES1Driver::createScreenShot(video::ECOLOR_FORMAT format, video::E_RE void COGLES1Driver::removeTexture(ITexture* texture) { - if (!texture) - return; - + CacheHandler->getTextureCache().remove(texture); CNullDriver::removeTexture(texture); } diff --git a/tests/irrString.cpp b/tests/irrString.cpp index 08ff6728..f2ce776c 100644 --- a/tests/irrString.cpp +++ b/tests/irrString.cpp @@ -260,6 +260,14 @@ bool testFindFunctions() if ( p >= 0 ) return false; + irr::core::stringc lastX("max"); + p = lastX.findLastCharNotInList("x",1); + if ( p != 1 ) + return false; + p = lastX.findLastCharNotInList("y",1); + if ( p != 2 ) + return false; + p = empty.findLast('x'); if ( p >= 0 ) return false; @@ -279,6 +287,29 @@ bool testFindFunctions() return true; } +bool testErase() +{ + if ( stringc(1.f).eraseTrailingFloatZeros() != stringc("1") ) + return false; + + if ( stringc("0.100000").eraseTrailingFloatZeros() != stringc("0.1") ) + return false; + + if ( stringc("10.000000").eraseTrailingFloatZeros() != stringc("10") ) + return false; + + if ( stringc("foo 3.140000").eraseTrailingFloatZeros() != stringc("foo 3.14") ) + return false; + + if ( stringc("no_num.000").eraseTrailingFloatZeros() != stringc("no_num.000") ) + return false; + + if ( stringc("1.").eraseTrailingFloatZeros() != stringc("1.") ) + return false; + + return true; +} + // Test the functionality of irrString /** Validation is done with assert_log() against expected results. */ bool testIrrString(void) @@ -347,6 +378,9 @@ bool testIrrString(void) logTestString("test find functions\n"); allExpected &= testFindFunctions(); + logTestString("test erase functions\n"); + allExpected &= testErase(); + if(allExpected) logTestString("\nAll tests passed\n"); else diff --git a/tests/media/OpenGL-orthoCam.png b/tests/media/OpenGL-orthoCam.png index e0a32eca..d1fa7f3a 100644 Binary files a/tests/media/OpenGL-orthoCam.png and b/tests/media/OpenGL-orthoCam.png differ diff --git a/tests/orthoCam.cpp b/tests/orthoCam.cpp index e7feee4b..1e499325 100644 --- a/tests/orthoCam.cpp +++ b/tests/orthoCam.cpp @@ -16,7 +16,7 @@ static bool testOrthoCam(video::E_DRIVER_TYPE driverType) scene::ICameraSceneNode* cam = device->getSceneManager()->addCameraSceneNode(); cam->setPosition(core::vector3df(500,200,-500)); cam->setTarget(core::vector3df()); - cam->setProjectionMatrix(core::matrix4().buildProjectionMatrixOrthoLH(240,180,0.9f,2000.f), true); + cam->setProjectionMatrix(core::matrix4().buildProjectionMatrixOrthoLH(240,180,0.9f,2000.f,driverType != video::EDT_OPENGL), true); device->getSceneManager()->addAnimatedMeshSceneNode(device->getSceneManager()->addHillPlaneMesh("plane", core::dimension2df(32,32), core::dimension2du(16,16)));//->setMaterialFlag(video::EMF_WIREFRAME, true); device->getSceneManager()->addCubeSceneNode(20.f)->setPosition(core::vector3df(50,20,50)); @@ -60,7 +60,7 @@ static bool testOrthoStencil(video::E_DRIVER_TYPE driverType) scene::ICameraSceneNode* cam = device->getSceneManager()->addCameraSceneNode(); cam->setPosition(core::vector3df(300,250,-300)); cam->setTarget(core::vector3df(0,20,0)); - cam->setProjectionMatrix(core::matrix4().buildProjectionMatrixOrthoLH(120,90,0.9f,2000.f), true); + cam->setProjectionMatrix(core::matrix4().buildProjectionMatrixOrthoLH(120,90,0.9f,2000.f,driverType != video::EDT_OPENGL), true); device->getSceneManager()->addAnimatedMeshSceneNode(device->getSceneManager()->addHillPlaneMesh("plane", core::dimension2df(32,32), core::dimension2du(16,16)));//->setMaterialFlag(video::EMF_WIREFRAME, true); @@ -74,7 +74,7 @@ static bool testOrthoStencil(video::E_DRIVER_TYPE driverType) light->setRadius(500.f); light->getLightData().DiffuseColor.set(0,1,1); - device->getVideoDriver()->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(0,0,0,0)); + device->getVideoDriver()->beginScene(video::ECBF_ALL, video::SColor(0,0,0,0)); device->getSceneManager()->drawAll(); device->getVideoDriver()->endScene(); diff --git a/tests/planeMatrix.cpp b/tests/planeMatrix.cpp index 1132a15b..30d46264 100644 --- a/tests/planeMatrix.cpp +++ b/tests/planeMatrix.cpp @@ -24,17 +24,24 @@ static bool transformPlane(const vector3df & point, const vector3df & normal, { plane3df plane(point, vector3df(normal).normalize()); - logTestString("\n Pre: (%.3ff,%.3ff,%.3ff), %.3ff\n", + logTestString("\n Pre N:(%.3ff,%.3ff,%.3ff), D:%.3ff\n", plane.Normal.X, plane.Normal.Y, plane.Normal.Z, plane.D); matrix.transformPlane(plane); - logTestString(" Post: (%.3ff,%.3ff,%.3ff), %.3ff\n", + logTestString(" Post N:(%.3ff,%.3ff,%.3ff), D:%.3ff\n", plane.Normal.X, plane.Normal.Y, plane.Normal.Z, plane.D); - logTestString("Expected: (%.3ff,%.3ff,%.3ff), %.3ff\n", + logTestString("Expected N:(%.3ff,%.3ff,%.3ff), D:%.3ff\n", expected.Normal.X, expected.Normal.Y, expected.Normal.Z, expected.D); + if(!plane.Normal.equals(vector3df(plane.Normal).normalize())) + { + logTestString("Plane normal no longer normalized after transformation\n"); + assert_log(false); + return false; + } + if(!sloppyComparePlanes(plane, expected)) { logTestString("Unexpected result\n"); @@ -149,14 +156,14 @@ bool planeMatrix(void) matrix[4], matrix[5], matrix[6], matrix[7], matrix[8], matrix[9], matrix[10], matrix[11], matrix[12], matrix[13], matrix[14], matrix[15]); - success &= transformPlane(vector3df(0, 0, 0), vector3df(-1, -1, 0), matrix, plane3df(vector3df(-0.707f,-0.354f,0.000f), -0.000f)); - success &= transformPlane(vector3df(0, 0, 0), vector3df(1, 1, 0), matrix, plane3df(vector3df(0.707f,0.354f,0.000f), -0.000f)); - success &= transformPlane(vector3df(0, 0, 0), vector3df(-1, 1, 0), matrix, plane3df(vector3df(-0.707f,0.354f,0.000f), -0.000f)); - success &= transformPlane(vector3df(0, 0, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.707f,-0.354f,0.000f), -0.000f)); - success &= transformPlane(vector3df(0, 1, 0), vector3df(-1, -1, 0), matrix, plane3df(vector3df(-0.707f,-0.354f,0.000f), 0.707f)); - success &= transformPlane(vector3df(0, 1, 0), vector3df(1, 1, 0), matrix, plane3df(vector3df(0.707f,0.354f,0.000f), -0.707f)); - success &= transformPlane(vector3df(0, 1, 0), vector3df(-1, 1, 0), matrix, plane3df(vector3df(-0.707f,0.354f,0.000f), -0.707f)); - success &= transformPlane(vector3df(0, 1, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.707f,-0.354f,0.000f), 0.707f)); + success &= transformPlane(vector3df(0, 0, 0), vector3df(-1, -1, 0), matrix, plane3df(vector3df(-0.707f,-0.354f,0.000f).normalize(), -0.000f)); + success &= transformPlane(vector3df(0, 0, 0), vector3df(1, 1, 0), matrix, plane3df(vector3df(0.707f,0.354f,0.000f).normalize(), -0.000f)); + success &= transformPlane(vector3df(0, 0, 0), vector3df(-1, 1, 0), matrix, plane3df(vector3df(-0.707f,0.354f,0.000f).normalize(), -0.000f)); + success &= transformPlane(vector3df(0, 0, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.707f,-0.354f,0.000f).normalize(), -0.000f)); + success &= transformPlane(vector3df(0, 1, 0), vector3df(-1, -1, 0), matrix, plane3df(vector3df(-0.707f,-0.354f,0.000f).normalize(), 0.894f)); + success &= transformPlane(vector3df(0, 1, 0), vector3df(1, 1, 0), matrix, plane3df(vector3df(0.707f,0.354f,0.000f).normalize(), -0.894f)); + success &= transformPlane(vector3df(0, 1, 0), vector3df(-1, 1, 0), matrix, plane3df(vector3df(-0.707f,0.354f,0.000f).normalize(), -0.894f)); + success &= transformPlane(vector3df(0, 1, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.707f,-0.354f,0.000f).normalize(), 0.894f)); matrix = rotationMatrix * translationMatrix; logTestString("\nRotation * translation matrix\n%02.02f %02.02f %02.02f %02.02f" @@ -167,14 +174,14 @@ bool planeMatrix(void) matrix[4], matrix[5], matrix[6], matrix[7], matrix[8], matrix[9], matrix[10], matrix[11], matrix[12], matrix[13], matrix[14], matrix[15]); - success &= transformPlane(vector3df(0, 0, 0), vector3df(-1, -1, 0), matrix, plane3df(vector3df(-0.707f,0.000f,-0.707f), 2.121f)); - success &= transformPlane(vector3df(0, 0, 0), vector3df(1, 1, 0), matrix, plane3df(vector3df(0.707f,-0.000f,0.707f), -2.121f)); - success &= transformPlane(vector3df(0, 0, 0), vector3df(-1, 1, 0), matrix, plane3df(vector3df(-0.707f,-0.000f,0.707f), -2.121f)); - success &= transformPlane(vector3df(0, 0, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.707f,0.000f,-0.707f), 2.121f)); - success &= transformPlane(vector3df(0, 1, 0), vector3df(-1, -1, 0), matrix, plane3df(vector3df(-0.707f,0.000f,-0.707f), 2.828f)); - success &= transformPlane(vector3df(0, 1, 0), vector3df(1, 1, 0), matrix, plane3df(vector3df(0.707f,-0.000f,0.707f), -2.828f)); - success &= transformPlane(vector3df(0, 1, 0), vector3df(-1, 1, 0), matrix, plane3df(vector3df(-0.707f,-0.000f,0.707f), -2.828f)); - success &= transformPlane(vector3df(0, 1, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.707f,0.000f,-0.707f), 2.828f)); + success &= transformPlane(vector3df(0, 0, 0), vector3df(-1, -1, 0), matrix, plane3df(vector3df(-0.707f,0.000f,-0.707f).normalize(), 2.121f)); + success &= transformPlane(vector3df(0, 0, 0), vector3df(1, 1, 0), matrix, plane3df(vector3df(0.707f,-0.000f,0.707f).normalize(), -2.121f)); + success &= transformPlane(vector3df(0, 0, 0), vector3df(-1, 1, 0), matrix, plane3df(vector3df(-0.707f,-0.000f,0.707f).normalize(), -2.121f)); + success &= transformPlane(vector3df(0, 0, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.707f,0.000f,-0.707f).normalize(), 2.121f)); + success &= transformPlane(vector3df(0, 1, 0), vector3df(-1, -1, 0), matrix, plane3df(vector3df(-0.707f,0.000f,-0.707f).normalize(), 2.828f)); + success &= transformPlane(vector3df(0, 1, 0), vector3df(1, 1, 0), matrix, plane3df(vector3df(0.707f,-0.000f,0.707f).normalize(), -2.828f)); + success &= transformPlane(vector3df(0, 1, 0), vector3df(-1, 1, 0), matrix, plane3df(vector3df(-0.707f,-0.000f,0.707f).normalize(), -2.828f)); + success &= transformPlane(vector3df(0, 1, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.707f,0.000f,-0.707f).normalize(), 2.828f)); matrix = rotationMatrix * scaleMatrix; logTestString("\nRotation * scale matrix\n%02.02f %02.02f %02.02f %02.02f" @@ -185,14 +192,14 @@ bool planeMatrix(void) matrix[4], matrix[5], matrix[6], matrix[7], matrix[8], matrix[9], matrix[10], matrix[11], matrix[12], matrix[13], matrix[14], matrix[15]); - success &= transformPlane(vector3df(0, 0, 0), vector3df(-1, -1, 0), matrix, plane3df(vector3df(-0.707f,0.000f,-0.354f), -0.000f)); - success &= transformPlane(vector3df(0, 0, 0), vector3df(1, 1, 0), matrix, plane3df(vector3df(0.707f,-0.000f,0.354f), -0.000f)); - success &= transformPlane(vector3df(0, 0, 0), vector3df(-1, 1, 0), matrix, plane3df(vector3df(-0.707f,-0.000f,0.354f), -0.000f)); - success &= transformPlane(vector3df(0, 0, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.707f,0.000f,-0.354f), -0.000f)); - success &= transformPlane(vector3df(0, 1, 0), vector3df(-1, -1, 0), matrix, plane3df(vector3df(-0.707f,0.000f,-0.354f), 0.707f)); - success &= transformPlane(vector3df(0, 1, 0), vector3df(1, 1, 0), matrix, plane3df(vector3df(0.707f,-0.000f,0.354f), -0.707f)); - success &= transformPlane(vector3df(0, 1, 0), vector3df(-1, 1, 0), matrix, plane3df(vector3df(-0.707f,-0.000f,0.354f), -0.707f)); - success &= transformPlane(vector3df(0, 1, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.707f,0.000f,-0.354f), 0.707f)); + success &= transformPlane(vector3df(0, 0, 0), vector3df(-1, -1, 0), matrix, plane3df(vector3df(-0.707f,0.000f,-0.354f).normalize(), -0.000f)); + success &= transformPlane(vector3df(0, 0, 0), vector3df(1, 1, 0), matrix, plane3df(vector3df(0.707f,-0.000f,0.354f).normalize(), -0.000f)); + success &= transformPlane(vector3df(0, 0, 0), vector3df(-1, 1, 0), matrix, plane3df(vector3df(-0.707f,-0.000f,0.354f).normalize(), -0.000f)); + success &= transformPlane(vector3df(0, 0, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.707f,0.000f,-0.354f).normalize(), -0.000f)); + success &= transformPlane(vector3df(0, 1, 0), vector3df(-1, -1, 0), matrix, plane3df(vector3df(-0.707f,0.000f,-0.354f).normalize(), 0.894f)); + success &= transformPlane(vector3df(0, 1, 0), vector3df(1, 1, 0), matrix, plane3df(vector3df(0.707f,-0.000f,0.354f).normalize(), -0.894f)); + success &= transformPlane(vector3df(0, 1, 0), vector3df(-1, 1, 0), matrix, plane3df(vector3df(-0.707f,-0.000f,0.354f).normalize(), -0.894f)); + success &= transformPlane(vector3df(0, 1, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.707f,0.000f,-0.354f).normalize(), 0.894f)); matrix = translationMatrix * scaleMatrix; logTestString("\nTranslation * scale matrix\n%02.02f %02.02f %02.02f %02.02f" @@ -203,14 +210,14 @@ bool planeMatrix(void) matrix[4], matrix[5], matrix[6], matrix[7], matrix[8], matrix[9], matrix[10], matrix[11], matrix[12], matrix[13], matrix[14], matrix[15]); - success &= transformPlane(vector3df(0, 0, 0), vector3df(-1, -1, 0), matrix, plane3df(vector3df(-0.707f,-0.354f,0.000f), 1.061f)); - success &= transformPlane(vector3df(0, 0, 0), vector3df(1, 1, 0), matrix, plane3df(vector3df(0.707f,0.354f,0.000f), -1.061f)); - success &= transformPlane(vector3df(0, 0, 0), vector3df(-1, 1, 0), matrix, plane3df(vector3df(-0.707f,0.354f,0.000f), -1.061f)); - success &= transformPlane(vector3df(0, 0, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.707f,-0.354f,0.000f), 1.061f)); - success &= transformPlane(vector3df(0, 1, 0), vector3df(-1, -1, 0), matrix, plane3df(vector3df(-0.707f,-0.354f,0.000f), 1.768f)); - success &= transformPlane(vector3df(0, 1, 0), vector3df(1, 1, 0), matrix, plane3df(vector3df(0.707f,0.354f,0.000f), -1.768f)); - success &= transformPlane(vector3df(0, 1, 0), vector3df(-1, 1, 0), matrix, plane3df(vector3df(-0.707f,0.354f,0.000f), -1.768f)); - success &= transformPlane(vector3df(0, 1, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.707f,-0.354f,0.000f), 1.768f)); + success &= transformPlane(vector3df(0, 0, 0), vector3df(-1, -1, 0), matrix, plane3df(vector3df(-0.707f,-0.354f,0.000f).normalize(), 1.3416f)); + success &= transformPlane(vector3df(0, 0, 0), vector3df(1, 1, 0), matrix, plane3df(vector3df(0.707f,0.354f,0.000f).normalize(), -1.3416f)); + success &= transformPlane(vector3df(0, 0, 0), vector3df(-1, 1, 0), matrix, plane3df(vector3df(-0.707f,0.354f,0.000f).normalize(), -1.3416f)); + success &= transformPlane(vector3df(0, 0, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.707f,-0.354f,0.000f).normalize(), 1.3416f)); + success &= transformPlane(vector3df(0, 1, 0), vector3df(-1, -1, 0), matrix, plane3df(vector3df(-0.707f,-0.354f,0.000f).normalize(), 2.236f)); + success &= transformPlane(vector3df(0, 1, 0), vector3df(1, 1, 0), matrix, plane3df(vector3df(0.707f,0.354f,0.000f).normalize(), -2.236f)); + success &= transformPlane(vector3df(0, 1, 0), vector3df(-1, 1, 0), matrix, plane3df(vector3df(-0.707f,0.354f,0.000f).normalize(), -2.236f)); + success &= transformPlane(vector3df(0, 1, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.707f,-0.354f,0.000f).normalize(), 2.236f)); matrix = rotationMatrix * translationMatrix * scaleMatrix; logTestString("\nRotation * translation * scale matrix\n%02.02f %02.02f %02.02f %02.02f" @@ -221,14 +228,14 @@ bool planeMatrix(void) matrix[4], matrix[5], matrix[6], matrix[7], matrix[8], matrix[9], matrix[10], matrix[11], matrix[12], matrix[13], matrix[14], matrix[15]); - success &= transformPlane(vector3df(0, 0, 0), vector3df(-1, -1, 0), matrix, plane3df(vector3df(-0.707f,0.000f,-0.354f), 1.061f)); - success &= transformPlane(vector3df(0, 0, 0), vector3df(1, 1, 0), matrix, plane3df(vector3df(0.707f,-0.000f,0.354f), -1.061f)); - success &= transformPlane(vector3df(0, 0, 0), vector3df(-1, 1, 0), matrix, plane3df(vector3df(-0.707f,-0.000f,0.354f), -1.061f)); - success &= transformPlane(vector3df(0, 0, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.707f,0.000f,-0.354f), 1.061f)); - success &= transformPlane(vector3df(0, 1, 0), vector3df(-1, -1, 0), matrix, plane3df(vector3df(-0.707f,0.000f,-0.354f), 1.768f)); - success &= transformPlane(vector3df(0, 1, 0), vector3df(1, 1, 0), matrix, plane3df(vector3df(0.707f,-0.000f,0.354f), -1.768f)); - success &= transformPlane(vector3df(0, 1, 0), vector3df(-1, 1, 0), matrix, plane3df(vector3df(-0.707f,-0.000f,0.354f), -1.768f)); - success &= transformPlane(vector3df(0, 1, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.707f,0.000f,-0.354f), 1.768f)); + success &= transformPlane(vector3df(0, 0, 0), vector3df(-1, -1, 0), matrix, plane3df(vector3df(-0.707f,0.000f,-0.354f).normalize(), 1.3416f)); + success &= transformPlane(vector3df(0, 0, 0), vector3df(1, 1, 0), matrix, plane3df(vector3df(0.707f,-0.000f,0.354f).normalize(), -1.3416f)); + success &= transformPlane(vector3df(0, 0, 0), vector3df(-1, 1, 0), matrix, plane3df(vector3df(-0.707f,-0.000f,0.354f).normalize(), -1.3416f)); + success &= transformPlane(vector3df(0, 0, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.707f,0.000f,-0.354f).normalize(), 1.3416f)); + success &= transformPlane(vector3df(0, 1, 0), vector3df(-1, -1, 0), matrix, plane3df(vector3df(-0.707f,0.000f,-0.354f).normalize(), 2.236f)); + success &= transformPlane(vector3df(0, 1, 0), vector3df(1, 1, 0), matrix, plane3df(vector3df(0.707f,-0.000f,0.354f).normalize(), -2.236f)); + success &= transformPlane(vector3df(0, 1, 0), vector3df(-1, 1, 0), matrix, plane3df(vector3df(-0.707f,-0.000f,0.354f).normalize(), -2.236f)); + success &= transformPlane(vector3df(0, 1, 0), vector3df(1, -1, 0), matrix, plane3df(vector3df(0.707f,0.000f,-0.354f).normalize(), 2.236f)); success &= drawScaledOctree(); diff --git a/tests/tests-last-passed-at.txt b/tests/tests-last-passed-at.txt index 19710940..6f354ef6 100644 --- a/tests/tests-last-passed-at.txt +++ b/tests/tests-last-passed-at.txt @@ -1,4 +1,4 @@ Tests finished. 1 test of 1 passed. Compiled as DEBUG -Test suite pass at GMT Thu Jan 17 14:29:44 2019 +Test suite pass at GMT Fri Feb 22 17:53:28 2019