Commit Graph

408 Commits

Author SHA1 Message Date
cutealien
3752bd9bd4 Add more transparent node sorting algorithms
Adding 2 algorithms to sort by distance to camera plane instead of camera position.
This is better in quite a few situations and extra cost is just one vector subtraction per node and an additional function parameter per call, I think that's worth it. So made the camera-plane to object-center now the new default.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6573 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-11-22 16:34:55 +00:00
cutealien
3c4ac201ce Add options for transparency node sorting algorithm
Until last summer we sorted by object origin to camera distance
Since then we used nearest transformed bbox-extent to camera.
I've now added an enum to allow switching those plus 2 new:
- none (so sorting based on scenegraph instead)
- object center to camera. Which I made the new default as it worked the best in my tests.

I already experimented with a few more ones like different sphere sizes (bbox radius, minimal inbound radius, maximal inbound radius) around center or origin to handle objects with different sizes, but that just gave worse results for all my test cases.

Likely algorithms we should still try:
- Collision point with bounding-box in line between camera and object center (sounds a bit slow, but maybe worth it)
- Distance to camera plane (instead of camera position). But needs additional parameter to distance functions first (maybe normalized view vector will do). That should be useful when working with planar objects.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6572 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-11-22 14:52:19 +00:00
cutealien
ad4cd6ca7d Grammar
Had missing word in comment

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6571 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-11-13 15:04:40 +00:00
cutealien
8bf9cf5471 writeImageToFile param now used by CImageWriterPNG for compression level
A bit annoying that it kinda has the opposite meaning for png and jpg compression for same parameter (png compression goes up, jpg goes down).
Also unfortunate we chose u32 instead of int here or we could at least use the usual zlib value range for png.
But I think it still won't mess up in many cases. Defaults (value 0) stay the same as before.
And setting a jpg range <= 10 is rarely done and even if so it just changes png sizes a bit now if people use writer for both. 
People just have to be careful now when they override defaults for png and then also write jpg - but can't help it.
And it's too  useful to not have this - this can massively change the write-speed for png's (like up to 3 times faster with no compression on my system).

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6570 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-11-13 14:53:44 +00:00
cutealien
3fa020d03c Change how SMaterial handles equality for UserData for more flexibility
Different UserData values are no longer by default causing materials to be different.
It now always checks in this case the IUserData != operator.
This allows more user control. Can still have them be different by checking pointers in overloaded compare function.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6569 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-11-10 15:52:40 +00:00
cutealien
feaed624f7 Remove serialization again from IUserData
This can't work as on deserialize it would need to have the type for IUserData already.
And that's impossible with the way it's used right now.
Would need some kind of factory or so probably, but I'll ignore this for now.
Note that it's still possible to call some serialization manually on the derived classes by adding it there if needed.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6568 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-11-07 17:43:01 +00:00
cutealien
3c9a856e6d Add SMaterial::IUserData to make it easier passing additional values to shaders
Irrlicht generally avoided user pointers in the past, but after trying all kind of ugly workarounds - this is just easier and
not that much downsides really. Tiny speed costs due to additional SMaterial memory size and new comparison tests. 
But allows to keep SMaterial alive and useful for a while longer without needing a complete rewrite and it can now be used for stuff like writing PBR shaders.
Using a new interface io::IUserData for this which also allows serialization the user data (that part is untested so far, sorry)


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6567 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-11-07 15:43:49 +00:00
cutealien
d0605cf397 Update scene.irr test file to fix tests
LensShift got added recently.
Also there was some change in PolygonOffsetDirection longer ago (although that one didn't cause tests to fail)


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6566 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-11-07 15:11:54 +00:00
cutealien
d4f6d8c17b Add lens shift support for the camera and the perspective projection functions
As Blender docs describe it so nicely: Using lens shift is equivalent to rendering an image with a larger FOV and cropping it off-center.
This can be quite useful for architecture renderings, but I guess also has it's use in other situations.
Note: Didn't make the ICameraSceneNode functions pure virtual so users don't have to update their cameras for this
Also some change in serialization - same as in other places by now, do use existing values as defaults values when they are not found instead of resetting them to 0.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6565 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-10-19 16:04:43 +00:00
cutealien
567f8688e2 Mention in more places that ECFN_DISABLED disables zwrite as well
Easy to miss... 

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6564 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-10-18 16:51:56 +00:00
cutealien
2b08c37f89 CSoftwareTexture::lock no longer returns image data when a mipmapLevel is requested
Returns now getMipMapsData instead which for now will always be 0 in this case (but might work one day)
Also removing comment about ITexture::lock() mipmapLevel parameter being broken. It got fixed in November 2019.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6563 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-10-17 17:55:39 +00:00
cutealien
614308e19c Merging r6555 through r6560 from branch releases/1.8 to trunk
- Fixing buffer overflow in tga loader


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6561 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-10-16 20:59:41 +00:00
cutealien
e5c8a75d40 Document deviant ITexture::lock behaviour for EDT_SOFTWARE drivers
Software driver sometimes works with original image (in 2D) and sometimes with POT version of the image (in 3D).
That is probably useful so it can draw the UI in best quality while having relative fast 3D.
The problem is that lock() only returns one data - so it decided to return the original data and then in unlock it updates the other data. But lock() data usually depends on getSize() so using EDT_SOFTWARE like other drivers causes crashes.
Not sure what the best solution here would be (maybe more flags or more lock functions?), so I just document the deviating behaviour and leave it as is.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6559 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-10-15 21:38:06 +00:00
cutealien
f06347c8b7 Load top-down bmp images correctly
Previously we handled all sizes as unsigned, but Windows BMP files can have negative height to signal top-down images.
No clue about left-right (would be trivial to swap as well, but found no info so far if that would be correct)

Also casting away some new compile warning in gcc for COBJMeshFileLoader


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6558 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-10-05 21:04:55 +00:00
cutealien
099f83c023 Fix compiler warning in COBJMeshFileLoader
Caused by recent patches for 1.8 - which still had different parameter types in IReadFile::read

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6557 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-10-03 15:55:45 +00:00
cutealien
857c75f37d Merging r6555 from branch releases/1.8 to trunk
- Fixing buffer ovverread in CXMeshFileLoader (sfan5 patch)


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6556 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-10-03 15:21:39 +00:00
cutealien
b6e9202272 Merging r6551 through r6553 from branch releases/1.8 to trunk
All about bounds checks and preventing buffer overruns in b3d and obj files based on sfan5 patches for Minetest


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6554 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-10-03 15:08:40 +00:00
cutealien
b93dac3ee1 Merging r6547 from branch releases/1.8 to trunk
Just updating changes.txt (stuff got backported, so changes are now mentioned in 1.8.6 instead of 1.9)


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6550 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-10-03 12:56:33 +00:00
cutealien
7fd0f2b1fb COBJMeshFileLoader: Avoid memory leak when handling files with invalid vertex indices
Thanks @sfan5 for report and patch
Was part of the Minetest commit 80e1609 patch which was applied earlier
(couldn't apply this with the rest as the rest could be fixed in Irrlicht 1.8, while this one is about new Irrlicht 1.9 code)


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6548 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-10-02 21:49:08 +00:00
cutealien
5a6e8c9d65 Merging r6522 through r6546 from branch releases/1.8 to trunk
- Fixing buffer overflows in bmp and obj loaders
- Fixed loading of rle4 encoded bmp images


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6547 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-10-02 21:42:40 +00:00
cutealien
cd70803500 Add warning about rotateXZBy using right handed rotation
Rest of Irrlicht is using left-handed rotatations.
But 2d vector rotations all uses ccw which is kinda the same direction as this one if you consider those as rotations around Y, so I guess that was maybe the reason back then.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6536 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-09-26 21:31:35 +00:00
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
e81038237b Add some comment that camera FOV is vertical
Parameter already called fovy, but shouldn't hurt to mention it twice

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6531 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-09-23 14:24:36 +00:00
cutealien
7ff82528f3 Unify matrix4::buildProjectionMatrixPerspectiveFov functions
We had 4 near identical functions, those now all call buildProjectionMatrixPerspectiveFov
They were a bit hard to check for errors otherwise.
Especially with the tiny confusing non-differences like one using (a-b) and other -(b-a)
Also new one uses matrix template parameter in case someone needs for example a high-precision matrix.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6530 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-09-22 16:06:40 +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
dc6d89a170 Fix compiling example 21
Somehow was broken since fixing the spelling of tessellation and never noticed

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6523 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-08-13 15:25:54 +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
03fc9c73b5 Add missing word in changes.txt
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6517 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-08-03 19:09:22 +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
2bfe7506c2 Optimization in quaternion::rotationFromTo from Robert Eisele
Turns out we can avoid a square root and a division.
Patch comes even with proof: https://raw.org/proof/quaternion-from-two-vectors
(I also tested it a while and indeed got same results)


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6511 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-07-30 16:34:24 +00:00
cutealien
f7de9091a1 Remove comment that addRenderTargetTextureCubemap only works in d3d9
It works since quite a while also in OpenGL


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6510 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-07-28 13:48:12 +00:00
cutealien
27a73a81c6 Merging r6423 through r6505 from branch releases/1.8 to trunk
Those were backports from trunk to 1.8 so only changes.txt changed


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6506 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-07-26 15:31:41 +00:00
cutealien
35a0c4df8f Enhance shader material to show how to pass material values
Also document that gl_FrontMaterial is no longer supported in Irrlicht 1.9 (this has been the case for a few years, I just never noticed this was changed as I never even knew that was possible in the past...). Will keep it that way is it's definitely going in the right direction (getting rid of legacy support and going towards OpenGL core instead),

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6498 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-06-24 15:42:31 +00:00
cutealien
cdcb8274ee Improve documentation
What Irrlicht calls ShaderConstants is called uniforms by everyone else. So let's mention this at least.
Also reworked setVertexShaderConstant interface had an example for the old interface in the header.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6497 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-06-12 19:26:43 +00:00
cutealien
a44e5e3d17 Add updateBoundingBox parameter to IMeshBuffer::append and some fixes and optimizations
Fix: When appending to an empty mesh boundingbox has to be initialized with first position
Adding updateBoundingBox parameter as there is a bit costs involved in updating that and it might not be necessary at that point
Default is still to do it - and with the default parameter it's at least compile compatible to old interface (unless users created their own meshbuffers).
Optimizing the copying of vertices in CDynamicMeshBuffer::append by using memset when possible instead of pushing each vertex (which goes through quite a few virtual functions)

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6496 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-05-17 14:31:50 +00:00
cutealien
7c92944860 Don't let MeshBuffer append functions shrink memory as this prevents optimizations
Couldn't allocate enough memory before appending several buffers for all of them as first append shrunk the memory again.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6495 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-05-16 16:33:30 +00:00
cutealien
428fcca7fb CDynamicMeshBuffer::append can now handle appending meshbuffers with different vertex/index types
Doesn't change it's own type - so can still drop data. Or overflow 16-bit buffers (which creates broken models, but no crashes).
But it no longer has a problem adding 16-bit index-buffers to a 32-bit index-buffer for example.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6494 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-05-16 16:05:24 +00:00
cutealien
01588b58eb Get (more) append functions working for CMeshBuffer and CDynamicMeshBuffer
Some in CMeshBuffer got disabled in svn r1515 (before Irrlicht 1.7) without comment.
I suspect reason might have been that they are a bit unsafe and it was meant to be reworked. 
Maybe was planned to put that into MeshManipulator?
And CDynamicMeshBuffer never had them.
Anyway, it's useful stuff and having functions do nothing doesn't help. So now they do at least basic work.
Meaning - as long as index and vertex types are identical it's possible to attach meshbuffers again.
While totally ignoring things like 16-bit index overflow for now (so could be improved).
It would probably be better if attach functions had info about vertex/index types, but just keeping interface as it is/was for now.
This also fixes Bug #310 reported by Gaz.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6493 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-05-15 17:28:42 +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