Commit Graph

251 Commits

Author SHA1 Message Date
cutealien
298623541b Fix number overflows in TGA loader causing crashes
Image size calculation could overflow s32 in one place (but not others where it was done correct), which first lead to wrong amount of memory getting allocated for image data and later crash in the CColorConverter.
Thanks @sfan5 for his fuzzing tests @https://github.com/minetest/irrlicht/issues/236
and @erlehmann for passing them on: https://irrlicht.sourceforge.io/forum/viewtopic.php?t=52925
Also updating changes.txt with TGA loader changes from this and previous commits.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6535 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-09-23 19:01:01 +00:00
cutealien
9f48103263 Fix crash caused by memory overwriting in TGA loader caused by bad RLE data
From sfan5's fuzzing test reported in Minetest here: https://github.com/minetest/irrlicht/issues/236
Was missing test if it writes beyond allocated memory which can be triggered by TGA's which lie in their RLE data.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6534 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-09-23 18:33:46 +00:00
cutealien
74d3a9967f TGA images with palettes in 24 or 32 bit now create 32 bit images
Was creating 16-bit images for those before.
Could also support 24-bit images, but either we need another convert function or another palette for that (the 16 and 32 bit both work with 32 bit palettes, the 24 bit conversion function only with 24 bit palettes)

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6533 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-09-23 17:08:43 +00:00
cutealien
811a9f3463 Fix TGA's with bad palette colors reading from behind palette memory
TGA's can claim to use less palette colors than they later do.
We only support 8-bit palettes, so to make this safer lets just always allocate at least 256 bytes.
Thanks @erlehmann for report and testcase: https://irrlicht.sourceforge.io/forum/viewtopic.php?p=307191
Based on Minetest bug report: https://github.com/minetest/irrlicht/issues/236


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6532 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-09-23 16:34:42 +00:00
cutealien
c602a39598 Enable MultiProcessorCompilation in VC17 project file
No reason to not have several times faster build-times

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6529 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-08-17 10:12:28 +00:00
cutealien
bd4ce386a2 Clean-up include dependencies (video namespace)
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6528 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-08-15 18:42:05 +00:00
cutealien
ce1cdd2543 Clean-up include dependencies (scene namespace)
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6527 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-08-14 22:01:22 +00:00
cutealien
f83697d0bb Clean-up include dependencies
Files in irr namespace
Also some spelling fixes

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6526 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-08-14 20:38:23 +00:00
cutealien
80ce85ecc2 Clean-up include dependencies in gui and io modules
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6525 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-08-13 20:19:25 +00:00
cutealien
1d58677e18 Clean up include dependencies in public headers
Removing includes which were not needed by headers
Note that if you include those headers directly (instead of including irrlicht.h) you may have to add some new includes now.
Thought I generally tried to avoid removing headers where it leads to too much changes in user-code
Reason was mainly that IntelliSense in VisualStudio 17.7 added a new feature which shows those unused headers :)
Has to be used a bit careful as it doesn't know about defines and other platforms
And I only did clean up public headers so far (will probably do some more later or another time)

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6524 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-08-13 15:31:42 +00:00
cutealien
e2a742e2fc Fix compile error with OS X 10.10 SDK, bug #463
Thanks @Ryan Schmidt for report and patch: https://sourceforge.net/p/irrlicht/bugs/463


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6522 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-08-04 15:46:17 +00:00
cutealien
2149bfb317 Merging r6511 through r6520 from branch releases/1.8 to trunk
Note: Due to OSX always failing merge OSX it's rather applying a second patch
from Ryan Schmidt from bugreport #462 to trunk
(Not sure why svn merging always fails for OSX. Probably related to MacOSX files getting moved in the past. Was that done without svn move commands? I guess that can't be fixed anymore now)


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6521 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-08-04 10:22:58 +00:00
cutealien
6f60edbded Merging r6511 through r6515 from branch releases/1.8 to trunk
Note that 6514 couldn't be merged as the xcode project seems to have been rewritten and the irrFramework-Info.plist no longer exists in trunk.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6516 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-08-03 01:11:01 +00:00
cutealien
7ecaa18949 Merging r6506 through r6510 from branch releases/1.8 to trunk
Note those were mostly backport, so trunk already had most changes.
Also we've not merged all from 1.8 branch, will need another merge (backports tend to cause lots of ugly conflicts, so have to split this a bit)


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6515 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-08-03 00:59:44 +00:00
cutealien
31931b0455 Fix problems in rendering nodes outside SceneManager caused by new render-per-buffer code
Did no longer render nodes which were rendered in SceneManager + outside SceneManager if they didn't have the per-buffer-rendering enabled.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6491 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-05-09 10:11:49 +00:00
cutealien
79e435d02a Reduce header dependencies in IVideoDriver.h
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6490 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-05-08 16:19:31 +00:00
cutealien
2a04d747d1 Fix: r6469 broke fixed function materials when shader materials where created but not used
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6489 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-05-08 14:15:49 +00:00
cutealien
c57da57edc Remove IMaterialRendererServices::setBasicRenderStates
Wasn't ever used by anything and not that well defined anyway.
So they all just passed it on to the drivers. And then sometimes the driver version was called and sometimes the IMaterialRendererServices version. So now everything just calls the driver - all places which need it have access to the driver anyway. Also made the driver version non-virtual for now. If someone actually really needs this for some reason I can add it back as virtual function directly in IVideoDriver. But I doubt it - the interface was hardly accessible until recently and originally only meant for internal stuff.
GLES version still to do, but checked them earlier and they also just do nothing with it.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6486 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-05-05 18:47:22 +00:00
cutealien
c928d1e1a6 Unify newlines
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6484 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-05-05 12:30:28 +00:00
cutealien
c4504c1d48 Add IMeshSceneNode::setNodeRegistration to allow registering MeshSceneNodes to the SceneManager per buffer instead of per node
So far SceneManager always sorted Nodes per render stage.
Now we allow sorting per mesh-buffer per render stage by creating a new node for each mesh-buffer.
It's only supported for CMeshSceneNode so far.

This allows to enable better transparency sorting for meshes which have transparent buffers.
Previously those always got rendered in the order in which they got added and ignored mesh-buffer bounding-boxes, but just used the bbox of the full mesh. Now they can use the bbox for each meshbuffer which can sometimes avoid render errors.

Also depending on the scene this can be quite a bit faster because it can help reduce texture changes. We sort solid nodes per texture, but only per node. So nodes with several textures had a texture switch between rendering each meshbuffer. And those are rather expensive in Irrlicht right now (and we support no bindless textures yet...)

Lastly it's now also used to buffer the render-stage. Checking this twice (once in registering the node and once in render) constantly showed up in the profiler. Which was a bit surprising really, but anyway - now it's gone.

I tried to keep it working for all cases we had before (all kind of situations, like when people may want to call render() outside the SceneManager). But not (yet) supporting the case of changing the meshbuffers (adding or removing some) without calling setMesh() again. Reason is that this wasn't well supported before either (node materials never updated). So for now I just assume people will call setMesh() again when they change the mesh.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6483 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-05-04 16:07:18 +00:00
cutealien
1b4912fcc4 Collada loader can now handle 32-bit meshbuffers
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6480 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-04-29 15:12:49 +00:00
cutealien
13619d8fdf Remove unused variable in CGUIContextMenu
y was set in 2 places, but never used for anything.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6476 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-04-27 19:46:05 +00:00
cutealien
36fc0bc8d2 Spelling fixes
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6475 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-04-27 18:44:33 +00:00
cutealien
80788a4198 More fixes for CCubeSceneNode with multi-material cube
CCubeSceneNode::getMaterialCount now returning correct count
CCubeSceneNode::clone now cloning all materials

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6474 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-04-27 12:58:55 +00:00
cutealien
8b0534d4b7 Fix CCubeSceneNode using correct material per side for multi-material cubes
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6473 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-04-27 12:50:20 +00:00
cutealien
28856e78b6 CCubeSceneNode can now handle new multi-material cube type
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6472 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-04-26 18:52:08 +00:00
cutealien
e55af78b31 No longer move context sub-menu to left if there's even less space there
Probably still moving too often to the left - should find some better solution.
But at least some improvement.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6471 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-04-25 13:14:52 +00:00
cutealien
37d821dcc3 Add MaterialType in COpenGLSLMaterialRenderer::OnSetMaterial back in
Shouldn't have been removed with last commit.
But adding some comments as it's slightly confusing.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6470 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-04-24 16:01:13 +00:00
cutealien
c4bbbe1aaf Add IMaterialRendererServices::startUseProgram/stopUseProgram
This makes it possible to set high-level shader constants (which are attached to shader programs) to be set outside
of OnSetConstants.
IShaderConstantSetCallBack::OnCreate has it set automatically now so it works the same as OnSetConstants.
D3D9 and burnings both work different, so there hadn't been a problem with those.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6469 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-04-24 14:46:09 +00:00
cutealien
16c960c5ed Add IShaderConstantSetCallBack::OnCreate to allow earlier access to IMaterialRendererServices
Accessing IMaterialRendererServices outside of OnSetConstants can be useful and Irrlicht made this a bit too hard to access.
Also OnCreate allows actually for nicer code where initialization and update of shader constants are strictly separated (see changed example).

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6465 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-04-21 14:41:01 +00:00
cutealien
02165eccc8 CD3D9HLSLMaterialRenderer now implementing IMaterialRendererServices itself
Basically now the same as GLSL material renderer already worked.
Before it was using IMaterialRendererServices from CD3D9Driver, but there had been several problems with that:
- The d3d9 driver called functions through the CD3D9MaterialRenderer interface, but CD3D9HLSLMaterialRenderer is not (or maybe no longer?) derived from that class. Reason it still worked was accidental luck - the same functions had been in the same order and due to casts the compiler wasn't noticing it was calling the functions of an unrelated class.
- It was making calls to set shader constants depend on the currently set material in the driver. Which was not necessary and just prevents we can use the IMaterialRendererServices interface without setting the material first (how I found the bug).
Still some problems left for now:
- There's 2 ways to call shader constants. One seems to be only used by hi-level shaders which links constants to the shader. The the other only by low-level shaders which uses global (shader independent) registers.
So maybe this should be 2 interfaces? But not certain, glsl material renderer seems to prevent setting the global registers, but maybe those could be used additionally? I've still allowed it for now in HLSL, just in case it had it's uses.
- setBasicRenderStates probably should not be in IMaterialRendererServices. I'm not seeing any case where this isn't just passed on to the driver. And all classes using it have access to the driver unless I missed one. So probably can just avoid that additional indirection and kick that out of the IMaterialRendererServices interface.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6464 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-04-21 14:04:57 +00:00
cutealien
ce3dcfde56 Fix recently broken scroll behaviour of listbox with moveOverSelect
This also fixes the combobox which users the listbox like that.
This got broken in [r6454] which had fixed the events send out by the listbox
Note: Still a bit strange behaviour when leaving the combobox at the bottom, but that was already that way in Irrlicht 1.8, so I've got to investigate that on it's own.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6463 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-04-19 15:17:39 +00:00
cutealien
41bc7a1430 Tiny spelling fixes
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6462 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-04-16 21:52:36 +00:00
cutealien
0887770a1e Fix spelling (comments)
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6461 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-04-12 13:22:03 +00:00
cutealien
f9a0cbbf95 Avoid warning in VS 2022
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6460 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-04-11 13:19:12 +00:00
cutealien
a3adfc196b CIrrDeviceWin32::yield() now uses Sleep(0) instead of Sleep(1).
We had changed that once before in the other direction in svn r421
Reason back then was "Sleep(0) doesn't allow any lower priority threads to execute"
But Microsoft changed the behaviour of Sleep(0) after Windows XP so that's no longer true.
And the costs of it is pretty high - due to this using a timer with a 15ms resolutions it meant not just giving up the thread but it also always waited for 15ms on Windows.
I also replaced a few sleep calls in examples for that reason with yield() calls.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6459 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-04-03 15:32:41 +00:00
cutealien
920e327d33 Spelling fixes
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6458 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-04-01 15:50:08 +00:00
cutealien
3a9875cc77 Spelling fixes
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6456 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-03-31 13:12:47 +00:00
cutealien
a23af985e4 Add ICursorControl::getReferenceRect
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6455 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-03-14 22:05:45 +00:00
cutealien
f989112dcb Fix: Listbox was sometimes sending EGET_LISTBOX_SELECTED_AGAIN instead of EGET_LISTBOX_CHANGED.
When pressed mouse was moved over an item before releasing the mouse button it was sending immediately EGET_LISTBOX_SELECTED_AGAIN instead of expected EGET_LISTBOX_CHANGED (mouse  move changes do not send any events).


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6454 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-03-06 14:34:16 +00:00
cutealien
75d485b5cd Listbox items can now change individual background colors
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6453 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-03-06 13:42:05 +00:00
cutealien
bda6bb8595 Avoid undefined arithmetic on nullptr in buffer_offset function
Not quite sure why it was done that way. Maybe to ensure we work with byte-pointers of correct size or something? 
Anyway, this doesn't seem to be defined in c++, so let's try working with a cast instead.
Just something cppcheck tool complained about.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6447 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-01-04 19:51:24 +00:00
cutealien
f2c93d80be Prevent memory leaks when loding broken ms3d files
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6446 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-01-04 19:02:42 +00:00
cutealien
817d59f379 Prevent potential 0 pointer access when release not acquired joystick.
Found by clang analyser. Not sure if it could really ever have happened, but won't hurt to fix

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6443 dfc29bdd-3216-0410-991c-e03cc46cb475
2022-11-19 16:41:11 +00:00
cutealien
fc96c50e53 Fix newly added Irrlicht17.sln file for VC2022
Was internally still using a VC16 project file

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6442 dfc29bdd-3216-0410-991c-e03cc46cb475
2022-11-19 14:28:27 +00:00
cutealien
f1a572e8a7 Add VC17 (VS 2022) project files and solutions
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6441 dfc29bdd-3216-0410-991c-e03cc46cb475
2022-11-19 14:22:50 +00:00
cutealien
3f00ea004e Avoid some broken calculations for IBoneSceneNode positions.
This is based on bugreport #458 reported by viwrap who also made a nice test-case model.
Note: While solution seems to work and would even be faster, I'm not 100% sure yet if there are no downsides.
The other solution seems to regard last column in matrices - thought I don't think we ever set or use that.
And I also haven't found out yet _why_ the original solution goes wrong. 
But animation system uses right-hand quaternions unlike rest of Irrlicht which is obviously a bit dangerous, will have to check the conversions some day.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6438 dfc29bdd-3216-0410-991c-e03cc46cb475
2022-10-11 22:54:44 +00:00
cutealien
41f2f8654f Fix warning
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6434 dfc29bdd-3216-0410-991c-e03cc46cb475
2022-10-04 12:32:27 +00:00
cutealien
b627ce805d Add option to allow nodes to ignore the scale/rotation parts of their parents transformation.
ISceneNode::setUpdateAbsolutePosBehavior can now control what ISceneNode::updateAbsolutePosition really does.
Having only the position and not the rotation/scale of a child node affected by the parent transformation was previously impossible inside the scene-graph. So people always had to break the scene-graph and code it themselves.
Old behaviour is default. 
Extra check for new variable has a small cost, thought new behaviour can actually be faster when it's used.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6432 dfc29bdd-3216-0410-991c-e03cc46cb475
2022-09-29 16:34:37 +00:00
cutealien
91f281229b Fix: Make CBillboardSceneNode bounding-box large enough to fit the billboard inside.
It still won't work yet for scaled boundingboxes (or parents being scaled). 
But at least it's now large enough for typical unscaled boundingboxes.
Before it was always too small - even for the simplest quadratic billboard case seen without rotation.
Now it's always a bit too large, but that's way less of a problem (collisions still work and culling simply happens a bit less often, but not too often which is way worse)

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6431 dfc29bdd-3216-0410-991c-e03cc46cb475
2022-09-29 14:12:12 +00:00