Merging r6519 through r6561 from trunk to ogl-es branch

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@6562 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien
2023-10-16 21:17:56 +00:00
parent e9c494503d
commit 849336343d
169 changed files with 465 additions and 511 deletions

View File

@ -5,7 +5,6 @@
#ifndef IRR_I_ANIMATED_MESH_H_INCLUDED
#define IRR_I_ANIMATED_MESH_H_INCLUDED
#include "aabbox3d.h"
#include "IMesh.h"
namespace irr

View File

@ -116,7 +116,7 @@ namespace scene
/** \return The aspect ratio of the camera. */
virtual f32 getAspectRatio() const =0;
//! Gets the field of view of the camera.
//! Gets the vertical field of view of the camera.
/** \return The field of view of the camera in radians. */
virtual f32 getFOV() const =0;
@ -135,7 +135,7 @@ namespace scene
\param aspect: New aspect ratio. */
virtual void setAspectRatio(f32 aspect) =0;
//! Sets the field of view (Default: PI / 2.5f)
//! Sets the vertical field of view (Default: PI / 2.5f)
/** Also changes projection matrix and resets IsOrthogonal flag.
\param fovy: New field of view in radians. */
virtual void setFOV(f32 fovy) =0;

View File

@ -7,7 +7,6 @@
#include "IMeshWriter.h"
#include "ISceneNode.h"
#include "IAnimatedMesh.h"
#include "SMaterial.h"
namespace irr

View File

@ -4,9 +4,8 @@
#ifndef IRR_I_GUI_IMAGE_LIST_H_INCLUDED
#define IRR_I_GUI_IMAGE_LIST_H_INCLUDED
#include "IGUIElement.h"
#include "rect.h"
#include "irrTypes.h"
#include "IReferenceCounted.h"
namespace irr
{

View File

@ -6,7 +6,6 @@
#define IRR_I_GUI_WINDOW_H_INCLUDED
#include "IGUIElement.h"
#include "EMessageBoxFlags.h"
namespace irr
{

View File

@ -10,7 +10,6 @@
#include "rect.h"
#include "SColor.h"
#include "irrAllocator.h"
#include <string.h>
namespace irr
{

View File

@ -6,7 +6,6 @@
#define IRR_I_IMAGE_WRITER_H_INCLUDED
#include "IReferenceCounted.h"
#include "irrString.h"
#include "coreutil.h"
namespace irr

View File

@ -6,7 +6,6 @@
#define IRR_I_INDEX_BUFFER_H_INCLUDED
#include "IReferenceCounted.h"
#include "irrArray.h"
#include "EHardwareBufferFlags.h"
#include "SVertexIndex.h"

View File

@ -8,7 +8,6 @@
#include "IReferenceCounted.h"
#include "path.h"
#include "IMeshTextureLoader.h"
#include "SVertexIndex.h"
namespace irr
{

View File

@ -7,7 +7,6 @@
#include "IReferenceCounted.h"
#include "irrArray.h"
#include "irrString.h"
#include "path.h"
#include "vector3d.h"
#include "dimension2d.h"

View File

@ -5,8 +5,6 @@
#ifndef IRR_I_SCENE_NODE_ANIMATOR_H_INCLUDED
#define IRR_I_SCENE_NODE_ANIMATOR_H_INCLUDED
#include "IReferenceCounted.h"
#include "vector3d.h"
#include "ESceneNodeAnimatorTypes.h"
#include "IAttributeExchangingObject.h"
#include "IAttributes.h"

View File

@ -6,7 +6,6 @@
#define IRR_I_SCENE_NODE_ANIMATOR_CAMERA_FPS_H_INCLUDED
#include "ISceneNodeAnimator.h"
#include "IEventReceiver.h"
#include "irrArray.h"
namespace irr

View File

@ -5,8 +5,6 @@
#ifndef IRR_I_SCENE_USER_DATA_SERIALIZER_H_INCLUDED
#define IRR_I_SCENE_USER_DATA_SERIALIZER_H_INCLUDED
#include "IReferenceCounted.h"
namespace irr
{
namespace io

View File

@ -6,9 +6,10 @@
#define IRR_I_SKINNED_MESH_H_INCLUDED
#include "irrArray.h"
#include "IBoneSceneNode.h"
#include "IAnimatedMesh.h"
#include "SSkinMeshBuffer.h"
#include "quaternion.h"
#include "irrString.h"
namespace irr
{

View File

@ -195,13 +195,17 @@ public:
//! Lock function.
/** Locks the Texture and returns a pointer to access the
pixels. After lock() has been called and all operations on the pixels
are done, you must call unlock().
Locks are not accumulating, hence one unlock will do for an arbitrary
number of previous locks. You should avoid locking different levels without
unlocking in between, though, because only the last level locked will be
unlocked.
are done, you must call unlock(). Locks are not accumulating, hence one
unlock will do for an arbitrary number of previous locks. You should avoid
locking different levels without unlocking in between, because only the
last level locked will be unlocked.
The size of the i-th mipmap level is defined as max(getSize().Width>>i,1)
and max(getSize().Height>>i,1)
and max(getSize().Height>>i,1).
Except for textures of EDT_SOFTWARE driver which returns data for
getOriginalSize(). Reason: Both original sized and modified sized textures are used
in that driver depending on whether the texture is used in 2d or 3d.
\param mode Specifies what kind of changes to the locked texture are
allowed. Unspecified behavior will arise if texture is written in read
only mode or read from in write only mode.

View File

@ -7,7 +7,6 @@
#include "SColor.h"
#include "matrix4.h"
#include "irrArray.h"
#include "irrMath.h"
#include "EMaterialTypes.h"
#include "EMaterialFlags.h"

View File

@ -8,9 +8,7 @@
#include "irrTypes.h"
#include "irrAllocator.h"
#include "irrMath.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
namespace irr
{

View File

@ -303,20 +303,33 @@ namespace core
\return Returns false if there is no inverse matrix. */
bool getInverse(CMatrix4<T>& out) const;
//! Tool function to build a perspective projection matrix
/** Mainly for use of the other perspective projection build functions.
But can also be used by users (can be useful if you don't work with matrices with T=f32).
\param sx: x scale factor (depth/half_width from clipped frustum planes parallel to the camera)
\param sy: y scale factor (depth/half_height from clipped frustum planes parallel to the camera)
\param zNear: Distance to near plane
\param zFar: Distance to far plane
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)
\param zSign: 1 for left-handed projection matrix, -1 for right-handed projection matrix */
CMatrix4<T>& buildProjectionMatrixPerspectiveFov(T sx, T sy, T zNear, T zFar, bool zClipFromZero, T zSign);
//! Builds a right-handed perspective projection matrix based on a field of view
//\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<T>& buildProjectionMatrixPerspectiveFovRH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar, bool zClipFromZero=true);
CMatrix4<T>& buildProjectionMatrixPerspectiveFovRH(f32 fieldOfViewRadiansY, f32 aspectRatio, f32 zNear, f32 zFar, bool zClipFromZero=true);
//! Builds a left-handed perspective projection matrix based on a field of view
CMatrix4<T>& buildProjectionMatrixPerspectiveFovLH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar, bool zClipFromZero=true);
CMatrix4<T>& buildProjectionMatrixPerspectiveFovLH(f32 fieldOfViewRadiansY, 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<T>& buildProjectionMatrixPerspectiveFovInfinityLH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 epsilon=0);
CMatrix4<T>& buildProjectionMatrixPerspectiveFovInfinityLH(f32 fieldOfViewRadiansY, f32 aspectRatio, f32 zNear, f32 epsilon=0);
//! Builds a right-handed perspective projection matrix.
CMatrix4<T>& buildProjectionMatrixPerspectiveRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero=true);
//! Builds a left-handed perspective projection matrix.
//\param widthOfViewVolume: width of clipped near frustum plane
//\param heightOfViewVolume: height of clipped near frustum plane
CMatrix4<T>& buildProjectionMatrixPerspectiveLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero=true);
//! Builds a left-handed orthogonal projection matrix.
@ -1568,102 +1581,70 @@ namespace core
}
// Builds a right-handed perspective projection matrix based on a field of view
// Builds a perspective projection matrix
template <class T>
inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixPerspectiveFovRH(
f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar, bool zClipFromZero)
inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixPerspectiveFov(T sx, T sy, T zNear, T zFar, bool zClipFromZero, T zSign)
{
const f64 h = reciprocal(tan(fieldOfViewRadians*0.5));
IRR_DEBUG_BREAK_IF(aspectRatio==0.f); //divide by zero
const T w = static_cast<T>(h / aspectRatio);
IRR_DEBUG_BREAK_IF(zNear==zFar); //divide by zero
M[0] = w;
M[0] = sx;
M[1] = 0;
M[2] = 0;
M[3] = 0;
M[4] = 0;
M[5] = (T)h;
M[5] = sy;
M[6] = 0;
M[7] = 0;
M[8] = 0;
M[9] = 0;
//M[10]
M[11] = -1;
//M[10] below
M[11] = zSign;
M[12] = 0;
M[13] = 0;
//M[14]
//M[14] below
M[15] = 0;
if ( zClipFromZero ) // DirectX version
{
M[10] = (T)(zFar/(zNear-zFar));
M[10] = zSign*zFar/(zFar-zNear);
M[14] = (T)(zNear*zFar/(zNear-zFar));
}
else // OpenGL version
{
M[10] = (T)((zFar+zNear)/(zNear-zFar));
M[10] = zSign*(zFar+zNear)/(zFar-zNear);
M[14] = (T)(2.0f*zNear*zFar/(zNear-zFar));
}
#if defined ( USE_MATRIX_TEST )
definitelyIdentityMatrix=false;
#endif
#if defined ( USE_MATRIX_TEST )
definitelyIdentityMatrix=false;
#endif
return *this;
}
// Builds a right-handed perspective projection matrix based on a field of view
template <class T>
inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixPerspectiveFovRH(
f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar, bool zClipFromZero)
{
const f64 sy = reciprocal(tan(fieldOfViewRadians*0.5));
IRR_DEBUG_BREAK_IF(aspectRatio==0.f); //divide by zero
const T sx = static_cast<T>(sy / aspectRatio);
return buildProjectionMatrixPerspectiveFov(sx, static_cast<T>(sy), zNear, zFar, zClipFromZero, (T)-1);
}
// Builds a left-handed perspective projection matrix based on a field of view
template <class T>
inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixPerspectiveFovLH(
f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar, bool zClipFromZero)
{
const f64 h = reciprocal(tan(fieldOfViewRadians*0.5));
const f64 sy = reciprocal(tan(fieldOfViewRadians*0.5));
IRR_DEBUG_BREAK_IF(aspectRatio==0.f); //divide by zero
const T w = static_cast<T>(h / aspectRatio);
IRR_DEBUG_BREAK_IF(zNear==zFar); //divide by zero
M[0] = w;
M[1] = 0;
M[2] = 0;
M[3] = 0;
M[4] = 0;
M[5] = (T)h;
M[6] = 0;
M[7] = 0;
M[8] = 0;
M[9] = 0;
//M[10]
M[11] = 1;
M[12] = 0;
M[13] = 0;
//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
return *this;
const T sx = static_cast<T>(sy / aspectRatio);
return buildProjectionMatrixPerspectiveFov(sx, static_cast<T>(sy), zNear, zFar, zClipFromZero, (T)1);
}
// Builds a left-handed perspective projection matrix based on a field of view, with far plane culling at infinity
template <class T>
inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixPerspectiveFovInfinityLH(
@ -1791,7 +1772,6 @@ namespace core
return *this;
}
// Builds a right-handed perspective projection matrix.
template <class T>
inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixPerspectiveRH(
@ -1799,45 +1779,11 @@ namespace core
{
IRR_DEBUG_BREAK_IF(widthOfViewVolume==0.f); //divide by zero
IRR_DEBUG_BREAK_IF(heightOfViewVolume==0.f); //divide by zero
IRR_DEBUG_BREAK_IF(zNear==zFar); //divide by zero
M[0] = (T)(2*zNear/widthOfViewVolume);
M[1] = 0;
M[2] = 0;
M[3] = 0;
M[4] = 0;
M[5] = (T)(2*zNear/heightOfViewVolume);
M[6] = 0;
M[7] = 0;
M[8] = 0;
M[9] = 0;
//M[10]
M[11] = -1;
M[12] = 0;
M[13] = 0;
//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
return *this;
const T sx = (T)(2*zNear/widthOfViewVolume);
const T sy = (T)(2*zNear/heightOfViewVolume);
return buildProjectionMatrixPerspectiveFov(sx, sy, zNear, zFar, zClipFromZero, (T)-1);
}
// Builds a left-handed perspective projection matrix.
template <class T>
inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixPerspectiveLH(
@ -1845,42 +1791,10 @@ namespace core
{
IRR_DEBUG_BREAK_IF(widthOfViewVolume==0.f); //divide by zero
IRR_DEBUG_BREAK_IF(heightOfViewVolume==0.f); //divide by zero
IRR_DEBUG_BREAK_IF(zNear==zFar); //divide by zero
M[0] = (T)(2*zNear/widthOfViewVolume);
M[1] = 0;
M[2] = 0;
M[3] = 0;
const T sx = (T)(2*zNear/widthOfViewVolume);
const T sy = (T)(2*zNear/heightOfViewVolume);
M[4] = 0;
M[5] = (T)(2*zNear/heightOfViewVolume);
M[6] = 0;
M[7] = 0;
M[8] = 0;
M[9] = 0;
//M[10]
M[11] = 1;
M[12] = 0;
M[13] = 0;
//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
return *this;
return buildProjectionMatrixPerspectiveFov(sx, sy, zNear, zFar, zClipFromZero, (T)1);
}
@ -2399,4 +2313,3 @@ namespace core
} // end namespace irr
#endif

View File

@ -235,7 +235,10 @@ namespace core
}
//! Rotates the vector by a specified number of degrees around the Y axis and the specified center.
/** \param degrees Number of degrees to rotate around the Y axis.
/** CAREFUL: For historical reasons rotateXZBy uses a right-handed rotation
(maybe to make it more similar to the 2D vector rotations which are counterclockwise).
To have this work the same way as rest of Irrlicht (nodes, matrices, other rotateBy functions) pass -1*degrees in here.
\param degrees Number of degrees to rotate around the Y axis.
\param center The center of the rotation. */
void rotateXZBy(f64 degrees, const vector3d<T>& center=vector3d<T>())
{