Closed AmyGilhespy closed 2 months ago
I'm not sure why, because I thought rotation would not need to touch UVs (or any other attribute attached to specific vertices) and only needs to affect positions and normals, but the problem maybe comes somehow from the fact UVs are gathered after rotation?
Rotation is done here: https://github.com/Zylann/godot_voxel/blob/87975a917ea7819cc5cbda1daa0f8497f62600dc/meshers/blocky/voxel_blocky_model_mesh.cpp#L229
And UVs are gathered in either of these places: https://github.com/Zylann/godot_voxel/blob/87975a917ea7819cc5cbda1daa0f8497f62600dc/meshers/blocky/voxel_blocky_model_mesh.cpp#L337 https://github.com/Zylann/godot_voxel/blob/87975a917ea7819cc5cbda1daa0f8497f62600dc/meshers/blocky/voxel_blocky_model_mesh.cpp#L371
Even then I dont think UVs should be modified though, but I'm also not sure why they do this, so I might be missing something. Order shouldn't matter... cuz UVs don't depend on positions. Haven't had a detailed look yet.
I checked the voxelgame demo, but I could not reproduce what you had.
However I noticed you looked at the multipass demo, which is a different library. So I had another look... And it turns out the log model is not a mesh model, it's a cube model, and that behavior was on purpose. The rotation buttons are shortcuts that target different properties depending on the type of model, which has different effect.
VoxelBlockyModelMesh
uses actual rotation of the vertices of the source mesh, therefore you would not see this happen with this kind of model (which is used in blocky_game). It modifies the mesh_ortho_rotation_index
property.
VoxelBlockyModelCube
rotation is implemented differently. It doesn't rotate the model, it rotates the faces on which textures are projected by changing the cube_tiles
properties, there is no mesh_ortho_rotation_index
property. Basically, it's not true rotation. This also goes for the "height" property, which is always applied to the top (it should also be noted that, because of this, directions on each tile property always corresponds to the same location relative to the axes, since the model itself doesn't rotate).
That makes sense. The reason I mentioned the multipass demo is indeed that it was the example that used the cube models, which we are trying to use in our project.
In our project, we are trying to make logs that rotate axially, but using the cube models it doesn't do a true rotation as you mentioned. If this is on purpose, is there any way around it with a cube model or should we switch to mesh models for things that rotate such as logs and such? As long as the performance is still good I'm not against switching to mesh models in my project -- the reason I chose cube models is because I assumed (without any testing!) that cube models would be more performant than mesh models where the model is just a cube anyway. If they are the same or similar then there's no need for us to use cube models in our project.
I just wonder what the use case of the cube model's rotation/direction/axial properties are if they aren't true rotations, as they seem hard at present to use for any real purpose in an actual game. Maybe I'm missing something here.
Thanks for your comments and explanation! I love your work on voxel tools. Keep it up! <3
If this is on purpose, is there any way around it with a cube model or should we switch to mesh models for things that rotate such as logs and such?
Currently you'd have to use mesh models. There is virtually no difference using one or the other in terms of performance.
I just wonder what the use case of the cube model's rotation/direction/axial properties are if they aren't true rotations
Cube models mostly exist as a shortcut so modeling is not necessary. Also, they don't have rotation/direction/axial properties. the buttons rotate the setup of tiles instead.
Thank you so much for the explanation! Take care.
I just pushed a change that makes rotation work the same with VoxelBlockyModelCube 01f8a1e9f7aad871580610522f3b7e5a8c74ceb0
Describe the bug Rotations do not orient all faces correctly, even in the voxelgame example project.
To Reproduce Steps to reproduce the behavior:
See also https://github.com/Zylann/godot_voxel/issues/694 which may be related.
Expected behavior The texture should rotate with the cube. For the log in the example project, the lines should face the rings no matter the orientation.
Screenshots
Environment
Godot Engine v4.3.1.rc.mono.custom_build - https://godotengine.org OpenGL API 3.3.0 - Build 27.20.100.9749 - Compatibility - Using Device: Intel - Intel(R) UHD Graphics 620