-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a way to create ArrayMesh from any Mesh resource #2249
Comments
The Godot editor can't depend on GDScript code by design. Everything must be written in C++. I've seen an editor plugin that could convert a CSG selection to a MeshInstance. It should be possible to achieve something similar with a MeshInstance (so you can convert a CubeMesh to an ArrayMesh). This can be done in either GDScript or C++. |
I know. That's why I said someone would have to Turn my GDScript Algorithms into C++ When I'm Done 😛 But we will get to that when and if/when I get the algorithms fully functional in GDScript and test it against the Currently used Godot Algorithms.. |
This is how I force csg to create a mesh. https://github.com/godotengine/godot/blob/master/modules/gltf/gltf_document.cpp#L5169 |
Do you have this as a project anywhere? |
My own attempt at implementing CSG? Only on my PC atm... Currently got as far as Separating Triangles that Do intersect with another mesh and those that don't. |
Is this Proposal concerning CSGMeshes, or PrimitiveMeshes, or both? Regarding PrimitiveMeshes, I bet we can make them just inherit from ArrayMesh instead of Mesh (and then contain proper UV2 channels as well so they can be used in baked lighting) |
It's about PrimitiveMeshes, CSG is where i've noticed the issue with the lack of ability to turn CubeMesh and SphereMesh and such into ArrayMesh for editing. |
In that case, this should be very easy. We should make PrimitiveMeshs inherit from ArrayMesh. It has always bothered me that they are so similar to ArrayMeshs but are completely incompatible. It has caused a lot of confusion for users too. |
An update on this. Reduz explained that PrimitveMeshes were designed to be lightweight so they shouldn't inherit all the bulk that comes with the ArrayMesh. Accordingly (for PrimitiveMeshes) we have two options:
I have already implemented 1, I think it makes more sense. a "Convert to ArrayMesh" button will make no sense if the user is already using an ArrayMesh. CSGMeshes are a whole other can of worms. I would argue that users are less likely to want to bake lighting for CSG meshes as they need to be dynamic. So I would approach them differently and perhaps add a "Bake Mesh" button that bakes the entire chain of CSG meshes into a single ArrayMesh. However, I can already foresee some problems with this approach like: what do we do about CSG nodes that have scripts attached? Or what if there are physics children to the nodes? You would only be able to bake CSG nodes that only had other CSG nodes as children (or you could choose to throw away everything that can't be baked). |
+1 to a bake mesh button on a CSG chain. I have used the script version of this that was posted in one of the issues, multiple times. Anything that isn't a CSG node could just be thrown away (and this behavior called out in the tooltip. |
I think it makes sense to provide a Convert to ArrayMesh option for primitive meshes. Maybe there should also be a method to do the same operation at run-time? I don't know if you can currently manipulate primitive meshes on the CPU at run-time (such as moving their vertices, painting their vertex colors and similar). For CSG, we could do the following:
|
Now that godotengine/godot#67975 is merged for UV2 on primitive meshes, are there other use cases for converting a PrimitiveMesh to an ArrayMesh? |
At this point, don't think there is any worth while reasons for this now.. |
Alright, closing then. |
Describe the project you are working on
Implementing my own CSG, as the CSG provided By Godot is Buggy (When I'm done, if it proves to be better (so no more issues like godotengine/godot#43755 and godotengine/godot#41140 and any others), I'll open a Proposal to change the current implementation (as Mine is in GDScript, and I'm not good at C++ so someone would have to do translating) and/or add it to the asset library)
Describe the problem or limitation you are having in your project
CubeMesh, SphereMesh and such cannot be Turned to ArrayMesh that is required to do any sort of mesh manipulation (as well as getting UV2 for Lightmaps done)
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Add a Button to turn a mesh into an ArrayMesh if it isn't one already (or isn't empty) much like the collision sibling creation is right now, that way the Primitives can easily be used for any of the ArrayMesh Specific applications.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Add Convert to Array Mesh Option and add a way to call that in code
If this enhancement will not be used often, can it be worked around with a few lines of script?
Yes, by using blender and exporting the primitives from there, but it's not a very fast and efficient method (compared to just having the option to do the conversion)
Is there a reason why this should be core and not an add-on in the asset library?
It's a Basic function that Godot currently doesn't have, and any addons would probably have to resolve it in some rather hacky ways
The text was updated successfully, but these errors were encountered: