Merging r6383 through r6403 from trunk to ogl-es branch

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@6404 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien
2022-05-15 16:02:08 +00:00
parent ec38b153da
commit ddc14ea87e
57 changed files with 337 additions and 282 deletions

View File

@ -186,7 +186,7 @@ namespace scene
SMD3QuaternionTag* get(const core::stringc& name)
{
SMD3QuaternionTag search ( name );
s32 index = Container.linear_search ( search );
const s32 index = Container.linear_search ( search );
if ( index >= 0 )
return &Container[index];
return 0;
@ -199,7 +199,7 @@ namespace scene
void set_used(u32 new_size)
{
s32 diff = (s32) new_size - (s32) Container.allocated_size();
const s32 diff = (s32) new_size - (s32) Container.allocated_size();
if ( diff > 0 )
{
SMD3QuaternionTag e("");

View File

@ -81,7 +81,7 @@ public:
{
const core::rect<s32>& r2 = Parent->getAbsolutePosition();
core::dimension2df d((f32)(r2.getSize().Width), (f32)(r2.getSize().Height));
const core::dimension2df d((f32)(r2.getSize().Width), (f32)(r2.getSize().Height));
if (AlignLeft == EGUIA_SCALE)
ScaleRect.UpperLeftCorner.X = (f32)r.UpperLeftCorner.X / d.Width;
@ -194,9 +194,8 @@ public:
if (Parent)
{
core::rect<s32> r(Parent->getAbsolutePosition());
core::dimension2df d((f32)r.getSize().Width, (f32)r.getSize().Height);
const core::rect<s32> r(Parent->getAbsolutePosition());
const core::dimension2df d((f32)r.getSize().Width, (f32)r.getSize().Height);
if (AlignLeft == EGUIA_SCALE)
ScaleRect.UpperLeftCorner.X = (f32)DesiredRect.UpperLeftCorner.X / d.Width;

View File

@ -49,14 +49,18 @@ namespace gui
//! returns string of a list item. the may id be a value from 0 to itemCount-1
virtual const wchar_t* getListItem(u32 id) const = 0;
//! adds an list item, returns id of item
virtual u32 addItem(const wchar_t* text) = 0;
//! adds an list item with an icon
/** \param text Text of list entry
\param icon Sprite index of the Icon within the current sprite bank. Set it to -1 if you want no icon
\return The id of the new created item */
virtual u32 addItem(const wchar_t* text, s32 icon) = 0;
virtual u32 addItem(const wchar_t* text, s32 icon=-1) = 0;
//! Insert the item at the given index
/** \return The index on success or -1 on failure. */
virtual s32 insertItem(u32 index, const wchar_t* text, s32 icon=-1) = 0;
//! set the item at the given index
virtual void setItem(u32 index, const wchar_t* text, s32 icon=-1) = 0;
//! Removes an item from the list
virtual void removeItem(u32 index) = 0;
@ -114,13 +118,6 @@ namespace gui
//! return the default color which is used for the given colorType
virtual video::SColor getItemDefaultColor(EGUI_LISTBOX_COLOR colorType) const = 0;
//! set the item at the given index
virtual void setItem(u32 index, const wchar_t* text, s32 icon) = 0;
//! Insert the item at the given index
/** \return The index on success or -1 on failure. */
virtual s32 insertItem(u32 index, const wchar_t* text, s32 icon) = 0;
//! Swap the items at the given indices
virtual void swapItems(u32 index1, u32 index2) = 0;

View File

@ -84,7 +84,7 @@ public:
}
//! Returns image data size in bytes
u32 getImageDataSizeInBytes() const
size_t getImageDataSizeInBytes() const
{
return getDataSizeFromFormat(Format, Size.Width, Size.Height);
}
@ -295,7 +295,7 @@ public:
}
else
{
u32 dataSize = 0;
size_t dataSize = 0;
u32 width = Size.Width;
u32 height = Size.Height;
@ -445,43 +445,57 @@ public:
}
}
//! calculate image data size in bytes for selected format, width and height.
static u32 getDataSizeFromFormat(ECOLOR_FORMAT format, u32 width, u32 height)
//! You should not create images where the result of getDataSizeFromFormat doesn't pass this function
/** Note that CImage does not yet check for this, but going beyond this limit is not supported well.
Image loaders should check for this.
If you don't have the format yet then checking width*height*bytes_per_pixel is mostly fine, but make
sure to work with size_t so it doesn't clip the result to u32 too early.
\return true when dataSize is small enough that it should be fine. */
static bool checkDataSizeLimit(size_t dataSize)
{
u32 imageSize = 0;
// 2gb for now. Could be we could do more on some platforms, but we still will run into
// problems right now then for example in then color converter (which currently still uses
// s32 for sizes).
return (size_t)(s32)(dataSize) == dataSize;
}
//! calculate image data size in bytes for selected format, width and height.
static size_t getDataSizeFromFormat(ECOLOR_FORMAT format, u32 width, u32 height)
{
size_t imageSize = 0;
switch (format)
{
case ECF_DXT1:
imageSize = ((width + 3) / 4) * ((height + 3) / 4) * 8;
imageSize = (size_t)((width + 3) / 4) * ((height + 3) / 4) * 8;
break;
case ECF_DXT2:
case ECF_DXT3:
case ECF_DXT4:
case ECF_DXT5:
imageSize = ((width + 3) / 4) * ((height + 3) / 4) * 16;
imageSize = (size_t)((width + 3) / 4) * ((height + 3) / 4) * 16;
break;
case ECF_PVRTC_RGB2:
case ECF_PVRTC_ARGB2:
imageSize = (core::max_<u32>(width, 16) * core::max_<u32>(height, 8) * 2 + 7) / 8;
imageSize = ((size_t)core::max_<u32>(width, 16) * core::max_<u32>(height, 8) * 2 + 7) / 8;
break;
case ECF_PVRTC_RGB4:
case ECF_PVRTC_ARGB4:
imageSize = (core::max_<u32>(width, 8) * core::max_<u32>(height, 8) * 4 + 7) / 8;
imageSize = ((size_t)core::max_<u32>(width, 8) * core::max_<u32>(height, 8) * 4 + 7) / 8;
break;
case ECF_PVRTC2_ARGB2:
imageSize = core::ceil32(width / 8.0f) * core::ceil32(height / 4.0f) * 8;
imageSize = (size_t)core::ceil32(width / 8.0f) * core::ceil32(height / 4.0f) * 8;
break;
case ECF_PVRTC2_ARGB4:
case ECF_ETC1:
case ECF_ETC2_RGB:
imageSize = core::ceil32(width / 4.0f) * core::ceil32(height / 4.0f) * 8;
imageSize = (size_t)core::ceil32(width / 4.0f) * core::ceil32(height / 4.0f) * 8;
break;
case ECF_ETC2_ARGB:
imageSize = core::ceil32(width / 4.0f) * core::ceil32(height / 4.0f) * 16;
imageSize = (size_t)core::ceil32(width / 4.0f) * core::ceil32(height / 4.0f) * 16;
break;
default: // uncompressed formats
imageSize = getBitsPerPixelFromFormat(format) / 8 * width;
imageSize = (size_t)getBitsPerPixelFromFormat(format) / 8 * width;
imageSize *= height;
break;
}

View File

@ -293,8 +293,8 @@ void IProfiler::stop(s32 id)
{
if ( Timer )
{
u32 timeNow = Timer->getRealTime();
s32 idx = ProfileDatas.binary_search(SProfileData(id));
const u32 timeNow = Timer->getRealTime();
const s32 idx = ProfileDatas.binary_search(SProfileData(id));
if ( idx >= 0 )
{
SProfileData &data = ProfileDatas[idx];
@ -303,7 +303,7 @@ void IProfiler::stop(s32 id)
{
// update data for this id
++data.CountCalls;
u32 diffTime = timeNow - data.LastTimeStarted;
const u32 diffTime = timeNow - data.LastTimeStarted;
data.TimeSum += diffTime;
if ( diffTime > data.LongestTime )
data.LongestTime = diffTime;
@ -336,7 +336,7 @@ s32 IProfiler::add(const core::stringw &name, const core::stringw &groupName)
}
else
{
s32 id = NextAutoId;
const s32 id = NextAutoId;
--NextAutoId;
add( id, name, groupName );
return id;
@ -400,7 +400,7 @@ bool IProfiler::findDataIndex(u32 & result, const core::stringw &name) const
const SProfileData* IProfiler::getProfileDataById(u32 id)
{
SProfileData data(id);
s32 idx = ProfileDatas.binary_search(data);
const s32 idx = ProfileDatas.binary_search(data);
if ( idx >= 0 )
return &ProfileDatas[idx];
return NULL;

View File

@ -30,7 +30,7 @@ namespace scene
core::triangle3df Triangle;
//! Triangle selector which contained the colliding triangle (useful when having MetaTriangleSelector)
ITriangleSelector* TriangleSelector;
const ITriangleSelector* TriangleSelector;
//! Node which contained the triangle (is 0 when selector doesn't have that information)
ISceneNode* Node;

View File

@ -736,7 +736,7 @@ namespace scene
IsVisible = in->getAttributeAsBool("Visible", IsVisible);
if (in->existsAttribute("AutomaticCulling"))
{
s32 tmpState = in->getAttributeAsEnumeration("AutomaticCulling",
const s32 tmpState = in->getAttributeAsEnumeration("AutomaticCulling",
scene::AutomaticCullingNames);
if (tmpState != -1)
AutomaticCullingState = (u32)tmpState;

View File

@ -49,7 +49,7 @@ struct SCollisionTriangleRange
irr::u32 RangeSize;
//! Real selector which contained those triangles (useful when working with MetaTriangleSelector)
ITriangleSelector* Selector;
const ITriangleSelector* Selector;
//! SceneNode from which the triangles are from
ISceneNode* SceneNode;

View File

@ -460,7 +460,7 @@ namespace video
/** Return value is the number of visible pixels/fragments.
The value is a safe approximation, i.e. can be larger than the
actual value of pixels. */
virtual u32 getOcclusionQueryResult(scene::ISceneNode* node) const =0;
virtual u32 getOcclusionQueryResult(const scene::ISceneNode* node) const =0;
//! Create render target.
virtual IRenderTarget* addRenderTarget() = 0;

View File

@ -618,6 +618,7 @@ namespace video
PolygonOffsetDirection = EPO_BACK;
PolygonOffsetSlopeScale = value?1.f:0.f;
PolygonOffsetDepthBias = value?1.f:0.f;
break;
default:
break;
}

View File

@ -47,7 +47,7 @@ inline bool hasFileExtension(const io::path& filename, const io::path& ext0,
//! cut the filename extension from a source file path and store it in a dest file path
inline io::path& cutFilenameExtension ( io::path &dest, const io::path &source )
{
s32 endPos = source.findLast ( '.' );
const s32 endPos = source.findLast ( '.' );
dest = source.subString ( 0, endPos < 0 ? source.size () : endPos );
return dest;
}
@ -55,7 +55,7 @@ inline io::path& cutFilenameExtension ( io::path &dest, const io::path &source )
//! get the filename extension from a file path
inline io::path& getFileNameExtension ( io::path &dest, const io::path &source )
{
s32 endPos = source.findLast ( '.' );
const s32 endPos = source.findLast ( '.' );
if ( endPos < 0 )
dest = "";
else
@ -176,7 +176,7 @@ static inline io::path mergeFilename(const io::path& path, const io::path& filen
if ( !result.empty() )
{
fschar_t last = result.lastChar();
const fschar_t last = result.lastChar();
if ( last != IRR_TEXT('/') && last != IRR_TEXT('\\') )
result += IRR_TEXT('/');
}

View File

@ -526,29 +526,31 @@ public:
}
//! Finds an element in linear time, which is very slow.
/** Use binary_search for faster finding. Only works if ==operator is
implemented.
\param element Element to search for.
//! Finds an element by searching linearly from array start to end
/** Can be slow with large arrays, try binary_search for those.
Only works if corresponding operator== is implemented.
\param element Element to search for.
\return Position of the searched element if it was found, otherwise -1
is returned. */
s32 linear_search(const T& element) const
template <class E>
s32 linear_search(const E& element) const
{
for (u32 i=0; i<used; ++i)
if (element == data[i])
if (data[i] == element)
return (s32)i;
return -1;
}
//! Finds an element in linear time, which is very slow.
/** Use binary_search for faster finding. Only works if ==operator is
implemented.
\param element: Element to search for.
//! Finds an element by searching linearly from array end to start.
/** Can be slow with large arrays, try binary_search for those.
Only works if corresponding operator== is implemented.
\param element Element to search for.
\return Position of the searched element if it was found, otherwise -1
is returned. */
s32 linear_reverse_search(const T& element) const
template <class E>
s32 linear_reverse_search(const E& element) const
{
for (s32 i=used-1; i>=0; --i)
if (data[i] == element)