Skip to content
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

Cannot change 'primitive_type' member when inheriting 'PrimitiveMesh' #77447

Closed
poirierlouis opened this issue May 24, 2023 · 4 comments
Closed

Comments

@poirierlouis
Copy link

poirierlouis commented May 24, 2023

Godot version

4.0.3-stable (5222a99)

System information

Windows 10

Issue description

Inheriting from PrimitiveMesh is limited. I try to create a custom BoxMesh but drawn using PRIMITIVE_LINES. However, from the child class, I cannot set the primitive_type of the parent class to use PRIMITIVE_LINES instead of the default PRIMITIVE_TRIANGLES value.

Steps to reproduce

  • Open Godot project below.
  • Run test.tscn to see the TestMesh drawn using PRIMITIVE_TRIANGLES.
  • Open test.gd to see there is no way to set PRIMITIVE_LINES.

Note: opening the scene in editor will spam an error (related to #59605) in Output tab.

Minimal reproduction project

2023-05-24_gd_issue_primitivemesh.zip

As a proposal, PrimitiveMesh could include a setter/getter on the primitive_type member. I'd be happy to contribute a PR if such a solution is accepted.

@clayjohn
Copy link
Member

I'm not sure this is a bug. The PrimitiveMesh is designed around having triangle meshes (except for the PointMesh). I think it would be easier to inherit from Mesh instead.

In other words, I don't think you gain much benefit from inheriting from PrimitiveMesh if you want to use a different primitive type

@poirierlouis
Copy link
Author

Well I first though it would better suit my purpose to reuse PrimitiveMesh.

I'm looking into the use of a Mesh instead. So far, it looks simpler to use a PrimitiveMesh as one only need to override a function and return an Array. Mesh introduce more complex logic with surface / bones ... and server side calls.

I understand that my use-case is not enough to introduce this change. Perhaps the documentation could be updated to clearly state what you explained? Maybe something like:

PrimitiveMesh should not be inherited by the user. Instead the user should prefer inheriting from Mesh. Even so, inheriting a PrimiveMesh is possible but comes with a limitation : it only allows the use of PRIMITIVE_TRIANGLES.

@AThousandShips
Copy link
Member

AThousandShips commented May 29, 2023

I'm not sure this is warranted, there's plenty of types that aren't intended to be inherited, and I don't really see that people would be likely to do so, and this isn't really not so either, it's just not as flexible as you assumed, clarifying this everywhere it might be relevant would bloat the documentation

@poirierlouis
Copy link
Author

there's plenty of types that aren't intended to be inherited

I did not realize it until I dig into the engine's code. I thought I could inherit PrimitiveMesh for my purpose, seeing how it was already inherited / used by the engine.

it's just not as flexible as you assumed

In deed, well I'll remember to check the engine's code first.

@poirierlouis poirierlouis closed this as not planned Won't fix, can't repro, duplicate, stale May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants