Commit 7809c481 authored by hybrid's avatar hybrid

Merged revisions 1972:2004 from 1.5 branch, except for some revisions which...

Merged revisions 1972:2004 from 1.5 branch, except for some revisions which seemed to be merged already. MD2 loader updated, terrain node fixed, opengl texture handling fixed.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2005 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 0ef1056e
...@@ -8,6 +8,11 @@ Changes in version 1.6 ...@@ -8,6 +8,11 @@ Changes in version 1.6
- Add a hitPosition out parameter to ISceneCollisionManager::getCollisionResultPosition() - this is a (small) API breaking change. - Add a hitPosition out parameter to ISceneCollisionManager::getCollisionResultPosition() - this is a (small) API breaking change.
-------------------------------------
Changes in version 1.5.1 (??.?? 2009)
- MD2 mesh loader: Now uses much less memory, reduced number of allocations when loading meshes.
----------------------------------- -----------------------------------
Changes in version 1.5 (15.12.2008) Changes in version 1.5 (15.12.2008)
......
This diff is collapsed.
...@@ -28,9 +28,6 @@ namespace scene ...@@ -28,9 +28,6 @@ namespace scene
//! destructor //! destructor
virtual ~CAnimatedMeshMD2(); virtual ~CAnimatedMeshMD2();
//! loads an md2 file
virtual bool loadFile(io::IReadFile* file);
//! returns the amount of frames in milliseconds. If the amount is 1, it is a static (=non animated) mesh. //! returns the amount of frames in milliseconds. If the amount is 1, it is a static (=non animated) mesh.
virtual u32 getFrameCount() const; virtual u32 getFrameCount() const;
...@@ -82,19 +79,16 @@ namespace scene ...@@ -82,19 +79,16 @@ namespace scene
//! \param nr: Zero based index of animation. //! \param nr: Zero based index of animation.
virtual const c8* getAnimationName(s32 nr) const; virtual const c8* getAnimationName(s32 nr) const;
private:
//! updates the interpolation buffer //
void updateInterpolationBuffer(s32 frame, s32 startFrame, s32 endFrame); // exposed for loader
//
//! calculates the bounding box
virtual void calculateBoundingBox();
//! the buffer that contains the most recent animation
SMeshBuffer* InterpolationBuffer; SMeshBuffer* InterpolationBuffer;
core::array<video::S3DVertex> *FrameList;
core::array<core::aabbox3d<f32> > BoxList;
struct SFrameData //! named animations
struct SAnimationData
{ {
core::stringc name; core::stringc name;
s32 begin; s32 begin;
...@@ -102,10 +96,44 @@ namespace scene ...@@ -102,10 +96,44 @@ namespace scene
s32 fps; s32 fps;
}; };
core::array< SFrameData > FrameData; //! scale and translations for keyframes
struct SKeyFrameTransform
{
core::vector3df scale;
core::vector3df translate;
};
//! md2 vertex data
struct SMD2Vert
{
core::vector3d<u8> Pos;
u8 NormalIdx;
};
//! keyframe transformations
core::array<SKeyFrameTransform> FrameTransforms;
//! keyframe vertex data
core::array<SMD2Vert> *FrameList;
//! bounding boxes for each keyframe
core::array<core::aabbox3d<f32> > BoxList;
//! named animations
core::array< SAnimationData > AnimationData;
//! calculates the bounding box
virtual void calculateBoundingBox();
u32 FrameCount; u32 FrameCount;
s32 TriangleCount; s32 TriangleCount;
private:
//! updates the interpolation buffer
void updateInterpolationBuffer(s32 frame, s32 startFrame, s32 endFrame);
}; };
} // end namespace scene } // end namespace scene
......
This diff is collapsed.
...@@ -11,6 +11,8 @@ namespace irr ...@@ -11,6 +11,8 @@ namespace irr
{ {
namespace scene namespace scene
{ {
class CAnimatedMeshMD2;
//! Meshloader capable of loading MD2 files //! Meshloader capable of loading MD2 files
class CMD2MeshFileLoader : public IMeshLoader class CMD2MeshFileLoader : public IMeshLoader
...@@ -30,6 +32,10 @@ public: ...@@ -30,6 +32,10 @@ public:
//! See IReferenceCounted::drop() for more information. //! See IReferenceCounted::drop() for more information.
virtual IAnimatedMesh* createMesh(io::IReadFile* file); virtual IAnimatedMesh* createMesh(io::IReadFile* file);
private:
//! Loads the file data into the mesh
bool loadFile(io::IReadFile* file, CAnimatedMeshMD2* mesh);
}; };
} // end namespace scene } // end namespace scene
......
...@@ -178,7 +178,7 @@ void COpenGLTexture::copyTexture(bool newTexture) ...@@ -178,7 +178,7 @@ void COpenGLTexture::copyTexture(bool newTexture)
break; break;
} }
glBindTexture(GL_TEXTURE_2D, TextureName); Driver->setTexture(0, this);
if (Driver->testGLError()) if (Driver->testGLError())
os::Printer::log("Could not bind Texture", ELL_ERROR); os::Printer::log("Could not bind Texture", ELL_ERROR);
...@@ -416,7 +416,7 @@ void COpenGLTexture::bindRTT() ...@@ -416,7 +416,7 @@ void COpenGLTexture::bindRTT()
//! Unbind Render Target Texture //! Unbind Render Target Texture
void COpenGLTexture::unbindRTT() void COpenGLTexture::unbindRTT()
{ {
glBindTexture(GL_TEXTURE_2D, getOpenGLTextureName()); Driver->setTexture(0, this);
// Copy Our ViewPort To The Texture // Copy Our ViewPort To The Texture
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, getSize().Width, getSize().Height); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, getSize().Width, getSize().Height);
...@@ -456,7 +456,7 @@ COpenGLFBOTexture::COpenGLFBOTexture(const core::dimension2d<s32>& size, ...@@ -456,7 +456,7 @@ COpenGLFBOTexture::COpenGLFBOTexture(const core::dimension2d<s32>& size,
// generate color texture // generate color texture
glGenTextures(1, &TextureName); glGenTextures(1, &TextureName);
glBindTexture(GL_TEXTURE_2D, TextureName); Driver->setTexture(0, this);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
......
This diff is collapsed.
// This is the entry point for the Irrlicht test suite. // This is the entry point for the Irrlicht test suite.
#define _CRT_SECURE_NO_WARNINGS // This is an MSVC pragma to link against the Irrlicht library.
// Other builds must link against it in the project files.
#include "testUtils.h" #if defined(_MSC_VER)
#include <stdio.h> #pragma comment(lib, "Irrlicht.lib")
#include <time.h> #define _CRT_SECURE_NO_WARNINGS
#include <assert.h> #endif // _MSC_VER
#include <vector>
#include "testUtils.h"
// This is an MSVC pragma to link against the Irrlicht library. #include <stdio.h>
// Other builds must link against it in the project files. #include <time.h>
#if defined(_MSC_VER) #include <assert.h>
#pragma comment(lib, "Irrlicht.lib")
#endif // _MSC_VER /* Each test must have the same signature. Test should (but are not
* required to) live in a .cpp file of the same name. There is no
typedef struct _STestDefinition * need to #include anything since the test entry points can be
{ * declared as extern before calling them.
bool(*testSignature)(void); */
const char * testName; #define RUN_TEST(testEntryPoint)\
} STestDefinition; extern bool testEntryPoint(void);\
logTestString("\nStarting test '" #testEntryPoint "'\n");\
//! This is the main entry point for the Irrlicht test suite. if(!testEntryPoint()) \
/** \return The number of test that failed, i.e. 0 is success. */ {\
int main(int argumentCount, char * arguments[]) (void)printf("\n\n\n******** Test failure ********\nTest '" #testEntryPoint "' failed\n"\
{ "******** Test failure ********\n\nPress return to continue\n");\
bool logFileOpened = openTestLog(1 == argumentCount); (void)getc(stdin);\
assert(logFileOpened); fails++;\
}
if(argumentCount > 3)
{ //! This is the main entry point for the Irrlicht test suite.
logTestString("\nUsage: %s [testNumber] [totalFails]\n"); /** \return The number of test that failed, i.e. 0 is success. */
closeTestLog(); int main(int argumentCount, char * arguments[])
return 9999; {
} bool logFileOpened = openTestLog(1 == argumentCount);
assert(logFileOpened);
#define TEST(x)\ if(argumentCount > 3)
{\ {
extern bool x(void);\ logTestString("\nUsage: %s [testNumber] [totalFails]\n");
STestDefinition newTest;\ closeTestLog();
newTest.testSignature = x;\ return 9999;
newTest.testName = #x;\ }
tests.push_back(newTest);\
} extern bool disambiguateTextures(void);
extern bool softwareDevice(void);
std::vector<STestDefinition> tests; extern bool exports(void);
extern bool testVector3d(void);
// Note that to interactively debug a test, you will generally want to move it extern bool testVector2d(void);
// (temporarily) to the beginning of the list, since each test runs in its own extern bool planeMatrix(void);
// process. extern bool fast_atof(void);
TEST(disambiguateTextures); // Normally you should run this first, since it validates the working directory. extern bool line2dIntersectWith(void);
TEST(vectorPositionDimension2d); extern bool drawPixel(void);
TEST(irrCoreEquals); extern bool md2Animation(void);
TEST(sceneNodeAnimator); extern bool b3dAnimation(void);
TEST(sceneCollisionManager); extern bool guiDisabledMenu(void);
TEST(collisionResponseAnimator); extern bool textureRenderStates(void);
TEST(exports);
TEST(testVector3d); typedef struct _STest
TEST(testVector2d); {
TEST(planeMatrix); bool(*testSignature)(void);
TEST(fast_atof); const char * testName;
TEST(line2dIntersectWith); } STest;
TEST(testDimension2d);
TEST(drawPixel); #define TEST(x) { x, #x }
TEST(md2Animation);
TEST(guiDisabledMenu); static const STest tests[] =
TEST(softwareDevice); {
TEST(b3dAnimation); TEST(disambiguateTextures), // Run this first, since it validates the WD.
TEST(terrainSceneNode); TEST(exports),
TEST(testVector3d),
const unsigned int numberOfTests = tests.size(); TEST(testVector2d),
TEST(planeMatrix),
unsigned int testToRun = 0; TEST(fast_atof),
unsigned int fails = 0; TEST(line2dIntersectWith),
TEST(drawPixel),
if(argumentCount > 1) TEST(md2Animation),
{ TEST(guiDisabledMenu),
testToRun = (unsigned int)atoi(arguments[1]); TEST(softwareDevice),
if(testToRun >= numberOfTests) TEST(b3dAnimation),
{ TEST(textureRenderStates)
logTestString("\nError: invalid test %d (maximum %d)\n", };
testToRun, numberOfTests - 1); static const unsigned int numberOfTests = sizeof tests / sizeof tests[0];
closeTestLog();
return 9999; unsigned int testToRun = 0;
} unsigned int fails = 0;
}
if(argumentCount > 1)
if(argumentCount > 2) {
fails = (unsigned int)atoi(arguments[2]); testToRun = (unsigned int)atoi(arguments[1]);
if(testToRun >= numberOfTests)
logTestString("\nStarting test %d, '%s'\n", {
testToRun, tests[testToRun].testName); logTestString("\nError: invalid test %d (maximum %d)\n",
testToRun, numberOfTests - 1);
bool success = tests[testToRun].testSignature(); closeTestLog();
return 9999;
if(!success) }
{ }
logTestString("\n\n\n******** Test failure ********\nTest %d '%s' failed\n"\
"******** Test failure ********\n", if(argumentCount > 2)
testToRun, tests[testToRun].testName); fails = (unsigned int)atoi(arguments[2]);
fails++;
} logTestString("\nStarting test %d, '%s'\n",
testToRun, tests[testToRun].testName);
testToRun++;
if(testToRun < numberOfTests) bool success = tests[testToRun].testSignature();
{
closeTestLog(); if(!success)
char runNextTest[256]; {
(void)sprintf(runNextTest, "\"%s\" %d %d", arguments[0], testToRun, fails); logTestString("\n\n\n******** Test failure ********\nTest %d '%s' failed\n"\
fails = system(runNextTest); "******** Test failure ********\n",
} testToRun, tests[testToRun].testName);
fails++;
if(1 == testToRun) }
{
(void)openTestLog(false); testToRun++;
const int passed = numberOfTests - fails;
if(testToRun == numberOfTests)
logTestString("\nTests finished. %d test%s of %d passed.\n", {
passed, 1 == passed ? "" : "s", numberOfTests); logTestString("\nTests finished. %d test%s failed.\n", fails, 1 == fails ? "" : "s");
if(0 == fails)
if(0 == fails) {
{ time_t rawtime;
time_t rawtime; struct tm * timeinfo;
struct tm * timeinfo; (void)time(&rawtime);
(void)time(&rawtime); timeinfo = gmtime(&rawtime);
timeinfo = gmtime(&rawtime); (void)printf("\nTest suite pass at GMT %s\n", asctime(timeinfo));
(void)printf("\nTest suite pass at GMT %s\n", asctime(timeinfo)); FILE * testsLastPassedAtFile = fopen("tests-last-passed-at.txt", "w");
FILE * testsLastPassedAtFile = fopen("tests-last-passed-at.txt", "w"); if(testsLastPassedAtFile)
if(testsLastPassedAtFile) {
{ (void)fprintf(testsLastPassedAtFile, "Test suite pass at GMT %s\n", asctime(timeinfo));
(void)fprintf(testsLastPassedAtFile, "Test suite pass at GMT %s\n", asctime(timeinfo)); (void)fclose(testsLastPassedAtFile);
(void)fclose(testsLastPassedAtFile); }
} }
} closeTestLog();
closeTestLog(); }
} else
{
return fails; closeTestLog();
} char runNextTest[256];
(void)sprintf(runNextTest, "\"%s\" %d %d", arguments[0], testToRun, fails);
fails = system(runNextTest);
}
return fails;
}
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="..\lib\Win32-visualstudio\Irrlicht.lib"
OutputFile="..\bin\Win32-VisualStudio\$(ProjectName).exe" OutputFile="..\bin\Win32-VisualStudio\$(ProjectName).exe"
GenerateDebugInformation="true" GenerateDebugInformation="true"
TargetMachine="1" TargetMachine="1"
...@@ -129,6 +130,7 @@ ...@@ -129,6 +130,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="..\lib\Win32-visualstudio\Irrlicht.lib"
OutputFile="..\bin\Win32-VisualStudio\$(ProjectName).exe" OutputFile="..\bin\Win32-VisualStudio\$(ProjectName).exe"
GenerateDebugInformation="true" GenerateDebugInformation="true"
OptimizeReferences="2" OptimizeReferences="2"
...@@ -246,6 +248,10 @@ ...@@ -246,6 +248,10 @@
RelativePath=".\testVector3d.cpp" RelativePath=".\testVector3d.cpp"
> >
</File> </File>
<File
RelativePath=".\textureRenderStates.cpp"
>
</File>
<File <File
RelativePath=".\vectorPositionDimension2d.cpp" RelativePath=".\vectorPositionDimension2d.cpp"
> >
......
// Copyright (C) 2008 Christian Stehno, Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "irrlicht.h"
#include "testUtils.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
//! Tests interleaved loading and rendering of textures
/** The test loads a texture, renders it using draw2dimage, loads another
texture and renders the first one again. Due to the texture cache this
can lead to rendering of the second texture in second place. */
static bool runTestWithDriver(E_DRIVER_TYPE driverType)
{
IrrlichtDevice *device = createDevice( driverType, dimension2d<s32>(160, 120), 32);
if (!device)
return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs
IVideoDriver* driver = device->getVideoDriver();
ISceneManager * smgr = device->getSceneManager();
ITexture* tex1 = driver->getTexture("../media/wall.bmp");
(void)smgr->addCameraSceneNode();
driver->beginScene(true, true, SColor(255,100,101,140));
driver->draw2DImage(tex1, position2di(0,0));
driver->endScene();
driver->getTexture("../media/tools.png");
driver->beginScene(true, true, SColor(255,100,101,140));
driver->draw2DImage(tex1, position2di(0,0));
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-textureRenderStates.png", 100);
device->drop();
return result;
}
bool textureRenderStates(void)
{
bool passed = true;
passed &= runTestWithDriver(EDT_SOFTWARE);
passed &= runTestWithDriver(EDT_BURNINGSVIDEO);
passed &= runTestWithDriver(EDT_DIRECT3D9);
passed &= runTestWithDriver(EDT_DIRECT3D8);
passed &= runTestWithDriver(EDT_OPENGL);
return passed;
}
...@@ -860,13 +860,11 @@ void CGUIEditWorkspace::PasteXMLToSelectedElement() ...@@ -860,13 +860,11 @@ void CGUIEditWorkspace::PasteXMLToSelectedElement()
// rewind file // rewind file
memWrite->seek(0, false); memWrite->seek(0, false);
io::IXMLReader* xmlReader = (io::IXMLReader*) Environment->getFileSystem()->createXMLReader(memWrite);
// read xml // read xml
Environment->readGUIElement(xmlReader, SelectedElement); Environment->loadGUI(memWrite, SelectedElement);
// drop the xml reader // reset focus
xmlReader->drop(); Environment->setFocus(this);
// drop the read file // drop the read file
memWrite->drop(); memWrite->drop();
......
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