Commit Graph

356 Commits

Author SHA1 Message Date
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
3683a2f8ee Reset last debug menu entry after reloaded the model in example 09
Reset 'em all! Was one short ;-)


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6485 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-05-05 17:45:35 +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
9679fa7006 Use ConstIterator instead of Iterator in a few places
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6482 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-05-02 18:43:45 +00:00
cutealien
04d814ee31 Allow nodes ignoring parent transformations with ESNUA_RELATIVE
New AbsPosUpdateBehavior which makes updateAbsolutePosition calls behave as if a node had no parent.
Allows for micro optimizations in cases where we have non-moving root node (all scenenodes are always added to the SceneManager which is generally not moved but it's transformation is still multiplied each frame for each node)
As a side-effect this also allows abusing the SceneManager to group objects without affecting transformations.
No real extra cost since I added ESNUA_TRANSFORM_POSITION already.
Thought turns out those matrix transformations are so fast that I also didn't noticed any difference in tests with > 20.000 nodes.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6481 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-05-02 16:05:22 +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
55e29d3347 Add SMaterialLayer::hasSetTextureMatrix and SMaterialLayer::resetTextureMatrix
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6479 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-04-28 17:46:30 +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
b4b28c367c Document some shader behaviour
S3DVertexTangents also documents that it's passed as TEXCOORD1 and TEXCOORD2, but easy to miss, so added some comments to the hlsl shader.
Also not all materials work well as base materials.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6452 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-02-28 20:21:00 +00:00
cutealien
538e3ab353 Add comment that xml reader returns EXN_UNKNOWN for xml header nodes
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6451 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-02-21 12:02:57 +00:00
cutealien
6c8767397b Add a comment to addSkyDomeSceneNode
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6450 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-02-05 13:29:51 +00:00
cutealien
3c8541d0c0 Rename variable ISceneNode::UpdateAbsolutePosBehavior -> AbsPosUpdateBehavior
Pretty new internal (protected) variable, so renaming shouldn't break yet too much.
Reason is that VS code completion often showed that variable as first option before the way more used updateAbsolutePosition function. Which was a bit annoying.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6449 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-01-23 21:12:06 +00:00
cutealien
cfc4b29a2c Use qualifed id instead of virtual function calls in CVertexBuffer constructors
Another find by cppcheck tool


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6448 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-01-19 23:26:20 +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
44a61505c4 Fix spelling of enums in header comments
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6445 dfc29bdd-3216-0410-991c-e03cc46cb475
2022-12-22 14:56:44 +00:00
cutealien
cfa42b743c Add comment that createScreenShot only supports ERT_FRAME_BUFFER
Thanks @Eduuu for bringing this to attention


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6444 dfc29bdd-3216-0410-991c-e03cc46cb475
2022-11-29 21:38:35 +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
e57a713377 Fix some bitfield sizes in SMaterial
Bitfields for PolygonOffsetDirection, ZWriteEnable and BlendOperation were chosen too small.
As we have pre c++11 code and therefore didn't use unsigned qualifiers for enums they were generally signed (up to compiler in theory, but I think they all choose signed).
Which means the bitfield also had a sign. 
So for example setting PolygonOffsetDirection to EPO_FRONT set it to -1 instead of 1.
Which then would fail with comparison checks (PolygonOffsetDirection == EPO_FRONT would be false).
We kind of got lucky that we usually not checked for the last enum inside Irrlicht, so it worked to due being the "else" case.
Or in the ZWriteEnable case the last one was identical to the default return value so it also worked accidentally.
But obviously still wrong and user code could be messed up.

While at it I also re-ordered SMaterial variable so most bitfield variables are close together again to give compiler at least a chance to use packing. Thought at least in my quick debug compile test it didn't seem to use any packing (but maybe on other compilers).

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6440 dfc29bdd-3216-0410-991c-e03cc46cb475
2022-11-17 16:42:39 +00:00
cutealien
3f372af486 Fix some problems with CMatrix4::getRotationDegrees
- Only the getRotationDegrees without parameter is allowed to try fixing scale.
  My fault when I added a new function which takes scale parameter, that one is 
  not allowed to be changed.
  On the up-side - we know have for the first time an option which works in cases only
  scale and rotation had been used and the user still has the correct scale. 
  Before any solution for that was broken
- getRotationDegrees fixes 2 places which caused wrong results due to floating point inaccuracies
  New test for that got added
- Document the current restrains and problems of getRotationDegrees and getScale some more.
- Improve docs for other matrix4 functions.
- Add some comments about further improvements (I'll try if I find time)

Note: Irrlicht still assumes in at least 2 places (getting bone animations and Collada loader) that matrix
decomposing works. Which it doesn't yet for matrices which switch handedness (or have further transformations like skewing axes)
The bone animation is mostly fine for now with recent workaround (but that might cause other problems as it may be used too often), haven't checked Collada yet in detail.

TL/DR: This improves things with getRotationDegrees, but does not yet fix all troubles.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6439 dfc29bdd-3216-0410-991c-e03cc46cb475
2022-10-15 15:46:03 +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
3c5a2387cf Handle missing 3d models in example 08
Ugly replacement if dwarf is missing.
Doing this because Debian currently discussing to remove the dwarf due to a conflict of it's license with Debian policy.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6436 dfc29bdd-3216-0410-991c-e03cc46cb475
2022-10-07 18:28:04 +00:00
cutealien
b3fff12423 Handle missing 3d models in example 07
No more crashing if some models are not found


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6435 dfc29bdd-3216-0410-991c-e03cc46cb475
2022-10-07 18:10:50 +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
51f1ff6716 Avoid newly introduced reorder warnings in ISceneNode
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6433 dfc29bdd-3216-0410-991c-e03cc46cb475
2022-09-29 19:03:51 +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
cutealien
5114c18b79 Fix and simplify IGUISpinBox::getOldValue
Was going wrong when setValue was called inside an event function for EGET_SPINBOX_CHANGED.
But last solution was overly complicated anyway as I tried too hard to avoid extra getValue calculations.
But noticing now those calculations got done anyway in all places where the event is triggered.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6430 dfc29bdd-3216-0410-991c-e03cc46cb475
2022-09-28 14:56:22 +00:00