Merge revision 5303:5311 from trunk to ogl-es

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@5312 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2016-07-08 22:11:55 +00:00
parent 2a7094889a
commit be5793727d
10 changed files with 133 additions and 50 deletions

View File

@ -8,6 +8,18 @@ Changes in ogl-es (not yet released - will be merged with trunk at some point)
-------------------------- --------------------------
Changes in 1.9 (not yet released) Changes in 1.9 (not yet released)
- Several fixes for SceneNodeAnimatorCollisionResponse, based on http://irrlicht.sourceforge.net/forum/viewtopic.php?f=7&t=33098&p=290746
Thanks to all people who reported and to JLouisB and kinkreet for the patches:
- Gravity is now fps independent
- Values of gravity now like documented (wasn't 1 unit = 1m before, had been 1m = current frames per second, so maybe 100 units = 1m).
Note that jump-values for fps-camera must also change when adapting gravity!
Several examples got adapted for new ranges.
- Pausing timer now pauses animator. Also doesn't reset values anymore with pauses.
- Clones no longer have 1000 times the gravity of original animator.
should now be fps independentn
- Speedup CTriangleSelector (mainly for animated meshes)
- CTriangleSelector now supports 32-bit meshbuffers. Thanks @Wol101 for reporting and patch-proposal.
- Fix: CTriangleSelector no longer resets it's boundingbox to 0,0,0 (was wrong when a meshbuffer was not around 0)
- Fix: Collada writer now uses wrap_p for third texture wrap value instead of invalid wrap_w (thx @Yoran for bugreport) - Fix: Collada writer now uses wrap_p for third texture wrap value instead of invalid wrap_w (thx @Yoran for bugreport)
- Several getter functions in IAttributes made const (thx @Erik Schultheis for the patch) - Several getter functions in IAttributes made const (thx @Erik Schultheis for the patch)
- Fix: CTriangleSelector no longer ignores meshbuffer transformations from skinned meshes (thx @AlexAzazel for report and test-model). - Fix: CTriangleSelector no longer ignores meshbuffer transformations from skinned meshes (thx @AlexAzazel for report and test-model).
@ -143,6 +155,9 @@ Changes in 1.9 (not yet released)
-------------------------- --------------------------
Changes in 1.8.4 Changes in 1.8.4
- Tests on Unix now have a short pause between switching drivers to avoid certain X11 errors.
- Fix CEnumAttribute::getInt() which could crash (thx @ luthyr for reporting)
- No longer try to run tests for drivers not supported on a platform
- Update lights and renderTargetTexture tests to work with Windows 10 (can't have so tiny Windows anymore). - Update lights and renderTargetTexture tests to work with Windows 10 (can't have so tiny Windows anymore).
- Deprecate CMatrix4::transformBox as the result is no longer a boundingbox. Use CMatrix4::transformBoxEx instead (which has been available for a long time). - Deprecate CMatrix4::transformBox as the result is no longer a boundingbox. Use CMatrix4::transformBoxEx instead (which has been available for a long time).
- Fix CSceneCollisionManager::getPickedNodeBB which could sometimes miss collisions. - Fix CSceneCollisionManager::getPickedNodeBB which could sometimes miss collisions.

View File

@ -119,7 +119,7 @@ int main()
values, the camera will be able to move closer to walls after this. The values, the camera will be able to move closer to walls after this. The
next parameter is the direction and speed of gravity. We'll set it to next parameter is the direction and speed of gravity. We'll set it to
(0, -10, 0), which approximates to realistic gravity, assuming that our (0, -10, 0), which approximates to realistic gravity, assuming that our
units are metres. You could set it to (0,0,0) to disable gravity. And the units are meters. You could set it to (0,0,0) to disable gravity. And the
last value is just a translation: Without this, the ellipsoid with which last value is just a translation: Without this, the ellipsoid with which
collision detection is done would be around the camera, and the camera would collision detection is done would be around the camera, and the camera would
be in the middle of the ellipsoid. But as human beings, we are used to have our be in the middle of the ellipsoid. But as human beings, we are used to have our
@ -132,7 +132,7 @@ int main()
// Set a jump speed of 3 units per second, which gives a fairly realistic jump // Set a jump speed of 3 units per second, which gives a fairly realistic jump
// when used with the gravity of (0, -10, 0) in the collision response animator. // when used with the gravity of (0, -10, 0) in the collision response animator.
scene::ICameraSceneNode* camera = scene::ICameraSceneNode* camera =
smgr->addCameraSceneNodeFPS(0, 100.0f, .3f, ID_IsNotPickable, 0, 0, true, 3.f); smgr->addCameraSceneNodeFPS(0, 100.0f, .3f, ID_IsNotPickable, 0, 0, true, 300.f);
camera->setPosition(core::vector3df(50,50,-60)); camera->setPosition(core::vector3df(50,50,-60));
camera->setTarget(core::vector3df(-70,30,-60)); camera->setTarget(core::vector3df(-70,30,-60));
@ -140,7 +140,7 @@ int main()
{ {
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator( scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
selector, camera, core::vector3df(30,50,30), selector, camera, core::vector3df(30,50,30),
core::vector3df(0,-10,0), core::vector3df(0,30,0)); core::vector3df(0,-1000,0), core::vector3df(0,30,0));
selector->drop(); // As soon as we're done with the selector, drop it. selector->drop(); // As soon as we're done with the selector, drop it.
camera->addAnimator(anim); camera->addAnimator(anim);
anim->drop(); // And likewise, drop the animator when we're done referring to it. anim->drop(); // And likewise, drop the animator when we're done referring to it.

View File

@ -316,7 +316,7 @@ void Q3Player::create ( IrrlichtDevice *device, IQ3LevelMesh* mesh, ISceneNode *
keyMap[9].Action = EKA_CROUCH; keyMap[9].Action = EKA_CROUCH;
keyMap[9].KeyCode = KEY_KEY_C; keyMap[9].KeyCode = KEY_KEY_C;
camera = smgr->addCameraSceneNodeFPS(0, 100.0f, 0.6f, -1, keyMap, 10, false, 0.6f); camera = smgr->addCameraSceneNodeFPS(0, 100.0f, 0.6f, -1, keyMap, 10, false, 600.f);
camera->setName ( "First Person Camera" ); camera->setName ( "First Person Camera" );
//camera->setFOV ( 100.f * core::DEGTORAD ); //camera->setFOV ( 100.f * core::DEGTORAD );
camera->setFarValue( 20000.f ); camera->setFarValue( 20000.f );

View File

@ -735,10 +735,10 @@ s32 Q3StartPosition ( IQ3LevelMesh* mesh,
*/ */
vector3df getGravity ( const c8 * surface ) vector3df getGravity ( const c8 * surface )
{ {
if ( 0 == strcmp ( surface, "earth" ) ) return vector3df ( 0.f, -90.f, 0.f ); if ( 0 == strcmp ( surface, "earth" ) ) return vector3df ( 0.f, -900.f, 0.f );
if ( 0 == strcmp ( surface, "moon" ) ) return vector3df ( 0.f, -6.f / 100.f, 0.f ); if ( 0 == strcmp ( surface, "moon" ) ) return vector3df ( 0.f, -6.f , 0.f );
if ( 0 == strcmp ( surface, "water" ) ) return vector3df ( 0.1f / 100.f, -2.f / 100.f, 0.f ); if ( 0 == strcmp ( surface, "water" ) ) return vector3df ( 0.1f, -2.f, 0.f );
if ( 0 == strcmp ( surface, "ice" ) ) return vector3df ( 0.2f / 100.f, -9.f / 100.f, 0.3f / 100.f ); if ( 0 == strcmp ( surface, "ice" ) ) return vector3df ( 0.2f, -9.f, 0.3f );
return vector3df ( 0.f, 0.f, 0.f ); return vector3df ( 0.f, 0.f, 0.f );
} }

View File

@ -328,14 +328,14 @@ void CDemo::switchToNextScene()
keyMap[8].Action = EKA_JUMP_UP; keyMap[8].Action = EKA_JUMP_UP;
keyMap[8].KeyCode = KEY_KEY_J; keyMap[8].KeyCode = KEY_KEY_J;
camera = sm->addCameraSceneNodeFPS(0, 100.0f, .4f, -1, keyMap, 9, false, 3.f); camera = sm->addCameraSceneNodeFPS(0, 100.0f, .4f, -1, keyMap, 9, false, 300.f);
camera->setPosition(core::vector3df(108,140,-140)); camera->setPosition(core::vector3df(108,140,-140));
camera->setFarValue(5000.0f); camera->setFarValue(5000.0f);
scene::ISceneNodeAnimatorCollisionResponse* collider = scene::ISceneNodeAnimatorCollisionResponse* collider =
sm->createCollisionResponseAnimator( sm->createCollisionResponseAnimator(
metaSelector, camera, core::vector3df(25,50,25), metaSelector, camera, core::vector3df(25,50,25),
core::vector3df(0, quakeLevelMesh ? -10.f : 0.0f,0), core::vector3df(0, quakeLevelMesh ? -1000.f : 0.0f,0),
core::vector3df(0,45,0), 0.005f); core::vector3df(0,45,0), 0.005f);
camera->addAnimator(collider); camera->addAnimator(collider);

View File

@ -1576,7 +1576,7 @@ public:
virtual void setEnum(const char* enumValue, const char* const* enumerationLiterals) _IRR_OVERRIDE_ virtual void setEnum(const char* enumValue, const char* const* enumerationLiterals) _IRR_OVERRIDE_
{ {
int literalCount = 0; u32 literalCount = 0;
if (enumerationLiterals) if (enumerationLiterals)
{ {
@ -1594,11 +1594,13 @@ public:
virtual s32 getInt() _IRR_OVERRIDE_ virtual s32 getInt() _IRR_OVERRIDE_
{ {
for (s32 i=0; EnumLiterals.size(); ++i) for (u32 i=0; i < EnumLiterals.size(); ++i)
{
if (Value.equals_ignore_case(EnumLiterals[i])) if (Value.equals_ignore_case(EnumLiterals[i]))
{ {
return i; return (s32)i;
} }
}
return -1; return -1;
} }

View File

@ -164,13 +164,13 @@ void CSceneNodeAnimatorCollisionResponse::animateNode(ISceneNode* node, u32 time
FirstUpdate = false; FirstUpdate = false;
} }
const u32 diff = timeMs - LastTime; const f32 diffSec = (f32)(timeMs - LastTime)*0.001f;
LastTime = timeMs; LastTime = timeMs;
CollisionResultPosition = Object->getPosition(); CollisionResultPosition = Object->getPosition();
core::vector3df vel = CollisionResultPosition - LastPosition; core::vector3df vel = CollisionResultPosition - LastPosition;
FallingVelocity += Gravity * (f32)diff * 0.001f; FallingVelocity += Gravity * diffSec;
CollisionTriangle = RefTriangle; CollisionTriangle = RefTriangle;
CollisionPoint = core::vector3df(); CollisionPoint = core::vector3df();
@ -188,20 +188,23 @@ void CSceneNodeAnimatorCollisionResponse::animateNode(ISceneNode* node, u32 time
= SceneManager->getSceneCollisionManager()->getCollisionResultPosition( = SceneManager->getSceneCollisionManager()->getCollisionResultPosition(
World, LastPosition-Translation, World, LastPosition-Translation,
Radius, vel, CollisionTriangle, CollisionPoint, f, Radius, vel, CollisionTriangle, CollisionPoint, f,
CollisionNode, SlidingSpeed, FallingVelocity); CollisionNode, SlidingSpeed, FallingVelocity*diffSec);
CollisionOccurred = (CollisionTriangle != RefTriangle); CollisionOccurred = (CollisionTriangle != RefTriangle);
CollisionResultPosition += Translation; CollisionResultPosition += Translation;
if (f)//CollisionTriangle == RefTriangle) if ( diffSec > 0 ) // don't change the state when there was no time
{ {
Falling = true; if (f)//CollisionTriangle == RefTriangle)
} {
else Falling = true;
{ }
Falling = false; else
FallingVelocity.set(0, 0, 0); {
Falling = false;
FallingVelocity.set(0, 0, 0);
}
} }
bool collisionConsumed = false; bool collisionConsumed = false;
@ -269,7 +272,7 @@ ISceneNodeAnimator* CSceneNodeAnimatorCollisionResponse::createClone(ISceneNode*
CSceneNodeAnimatorCollisionResponse * newAnimator = CSceneNodeAnimatorCollisionResponse * newAnimator =
new CSceneNodeAnimatorCollisionResponse(newManager, World, Object, Radius, new CSceneNodeAnimatorCollisionResponse(newManager, World, Object, Radius,
(Gravity * 1000.0f), Translation, SlidingSpeed); Gravity, Translation, SlidingSpeed);
newAnimator->cloneMembers(this); newAnimator->cloneMembers(this);
return newAnimator; return newAnimator;
} }

View File

@ -84,6 +84,30 @@ void CTriangleSelector::createFromMesh(const IMesh* mesh)
updateFromMesh(mesh); updateFromMesh(mesh);
} }
template <typename TIndex>
static void updateTriangles(u32& triangleCount, core::array<core::triangle3df>& triangles, u32 idxCnt, const TIndex* indices, const u8* vertices, u32 vertexPitch, const core::matrix4* bufferTransform)
{
if ( bufferTransform )
{
for (u32 index = 0; index < idxCnt; index += 3)
{
core::triangle3df& tri = triangles[triangleCount++];
bufferTransform->transformVect( tri.pointA, (*reinterpret_cast<const video::S3DVertex*>(&vertices[indices[index + 0]*vertexPitch])).Pos );
bufferTransform->transformVect( tri.pointB, (*reinterpret_cast<const video::S3DVertex*>(&vertices[indices[index + 1]*vertexPitch])).Pos );
bufferTransform->transformVect( tri.pointC, (*reinterpret_cast<const video::S3DVertex*>(&vertices[indices[index + 2]*vertexPitch])).Pos );
}
}
else
{
for (u32 index = 0; index < idxCnt; index += 3)
{
core::triangle3df& tri = triangles[triangleCount++];
tri.pointA = (*reinterpret_cast<const video::S3DVertex*>(&vertices[indices[index + 0]*vertexPitch])).Pos;
tri.pointB = (*reinterpret_cast<const video::S3DVertex*>(&vertices[indices[index + 1]*vertexPitch])).Pos;
tri.pointC = (*reinterpret_cast<const video::S3DVertex*>(&vertices[indices[index + 2]*vertexPitch])).Pos;
}
}
}
void CTriangleSelector::updateFromMesh(const IMesh* mesh) const void CTriangleSelector::updateFromMesh(const IMesh* mesh) const
{ {
@ -94,41 +118,54 @@ void CTriangleSelector::updateFromMesh(const IMesh* mesh) const
u32 meshBuffers = mesh->getMeshBufferCount(); u32 meshBuffers = mesh->getMeshBufferCount();
u32 triangleCount = 0; u32 triangleCount = 0;
BoundingBox.reset(0.f, 0.f, 0.f);
for (u32 i = 0; i < meshBuffers; ++i) for (u32 i = 0; i < meshBuffers; ++i)
{ {
IMeshBuffer* buf = mesh->getMeshBuffer(i); IMeshBuffer* buf = mesh->getMeshBuffer(i);
u32 idxCnt = buf->getIndexCount(); u32 idxCnt = buf->getIndexCount();
const u16* indices = buf->getIndices(); u32 vertexPitch = getVertexPitchFromType(buf->getVertexType());
u8* vertices = (u8*)buf->getVertices();
const core::matrix4* bufferTransform = 0;
if ( skinnnedMesh ) if ( skinnnedMesh )
{ {
const core::matrix4& bufferTransform = ((scene::SSkinMeshBuffer*)buf)->Transformation; bufferTransform = &(((scene::SSkinMeshBuffer*)buf)->Transformation);
for (u32 index = 0; index < idxCnt; index += 3) if ( bufferTransform->isIdentity() )
{ bufferTransform = 0;
core::triangle3df& tri = Triangles[triangleCount++];
bufferTransform.transformVect(tri.pointA, buf->getPosition(indices[index + 0]));
bufferTransform.transformVect(tri.pointB, buf->getPosition(indices[index + 1]));
bufferTransform.transformVect(tri.pointC, buf->getPosition(indices[index + 2]));
BoundingBox.addInternalPoint(tri.pointA);
BoundingBox.addInternalPoint(tri.pointB);
BoundingBox.addInternalPoint(tri.pointC);
}
} }
else
switch ( buf->getIndexType() )
{ {
for (u32 index = 0; index < idxCnt; index += 3) case video::EIT_16BIT:
{ {
core::triangle3df& tri = Triangles[triangleCount++]; const u16* indices = buf->getIndices();
tri.pointA = buf->getPosition(indices[index + 0]); updateTriangles(triangleCount, Triangles, idxCnt, indices, vertices, vertexPitch, bufferTransform);
tri.pointB = buf->getPosition(indices[index + 1]);
tri.pointC = buf->getPosition(indices[index + 2]);
BoundingBox.addInternalPoint(tri.pointA);
BoundingBox.addInternalPoint(tri.pointB);
BoundingBox.addInternalPoint(tri.pointC);
} }
break;
case video::EIT_32BIT:
{
const u32* indices = (u32*)buf->getIndices();
updateTriangles(triangleCount, Triangles, idxCnt, indices, vertices, vertexPitch, bufferTransform);
}
break;
} }
} }
// Update bounding box
if ( triangleCount )
{
BoundingBox.reset( Triangles[0].pointA );
for (u32 i=0; i < triangleCount; ++i)
{
const core::triangle3df& tri = Triangles[i];
BoundingBox.addInternalPoint(tri.pointA);
BoundingBox.addInternalPoint(tri.pointB);
BoundingBox.addInternalPoint(tri.pointC);
}
}
else
{
BoundingBox.reset(0.f, 0.f, 0.f);
}
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 622 B

After

Width:  |  Height:  |  Size: 608 B

View File

@ -5,15 +5,41 @@
#include "irrlicht.h" #include "irrlicht.h"
#include <assert.h> #include <assert.h>
// Small hack. Some newer X11 systems can't handle switching drivers too fast (causing BadWindow errors in X_ChangeWindowAttributes).
// Could be they don't like when Windows with different Visuals are created very quickly (it always happened after creating a new Window with different Visual to previous one).
// timeMs value set by try&error
#ifdef _IRR_POSIX_API_
#include <time.h>
#define SLOW_SWITCH \
do { \
struct timespec ts; \
const int timeMs = 250; \
ts.tv_sec = (time_t) (timeMs / 1000); \
ts.tv_nsec = (long) (timeMs % 1000) * 1000000; \
nanosleep(&ts, NULL);\
} while (false)
#else
#define SLOW_SWITCH
#endif
#define TestWithAllDrivers(X) \ #define TestWithAllDrivers(X) \
logTestString("Running test " #X "\n"); \ logTestString("Running test " #X "\n"); \
for (u32 i=1; i<video::EDT_COUNT; ++i) \ for (u32 i=1; i<video::EDT_COUNT; ++i) \
if ( video::E_DRIVER_TYPE(i) != video::DEPRECATED_EDT_DIRECT3D8_NO_LONGER_EXISTS ) \ if (video::E_DRIVER_TYPE(i) != video::DEPRECATED_EDT_DIRECT3D8_NO_LONGER_EXISTS && irr::IrrlichtDevice::isDriverSupported((irr::video::E_DRIVER_TYPE)i)) \
result &= X(video::E_DRIVER_TYPE(i)) {\
SLOW_SWITCH; \
result &= X(video::E_DRIVER_TYPE(i));\
}
#define TestWithAllHWDrivers(X) \ #define TestWithAllHWDrivers(X) \
SLOW_SWITCH; \
logTestString("Running test " #X "\n"); \ logTestString("Running test " #X "\n"); \
for (u32 i=video::EDT_DIRECT3D9; i<video::EDT_COUNT; ++i) \ for (u32 i=video::EDT_DIRECT3D9; i<video::EDT_COUNT; ++i) \
result &= X(video::E_DRIVER_TYPE(i)) if (irr::IrrlichtDevice::isDriverSupported((irr::video::E_DRIVER_TYPE)i)) \
{\
SLOW_SWITCH; \
result &= X(video::E_DRIVER_TYPE(i));\
}
// replacement for assert which does log the lines instead // replacement for assert which does log the lines instead
#define assert_log(X) \ #define assert_log(X) \