Open donn-xx opened 9 months ago
which does work but I am now not at all sure it's even supposed to, nor how long it will.
The intersect_ray
method is intended to work and is going to remain, it's used by the editor 🙂
Also, what is the difference between this "simple" approach and what Godot physics is already doing?
Quite extreme, the physics engine does a lot of tracking of objects moving, intersecting each other, etc. which isn't needed in the editor, but takes a lot of processing
I haven't dug into the ways the editor simulates these things without the physics engine but I suspect doing ray casting is much easier than shapes, and might not require some of the backing data structures
A lot can be done with just ray-casts, it's how the "snap to floor" method in the editor works for example
The
intersect_ray
method is intended to work and is going to remain, it's used by the editor 🙂
Okay. That's good to know.
Also, what is the difference between this "simple" approach and what Godot physics is already doing?
Quite extreme, the physics engine does a lot of tracking of objects moving, intersecting each other, etc. which isn't needed in the editor, but takes a lot of processing
Fair enough. Is there a case for an editor-available API for non-moving intersections?
A lot can be done with just ray-casts, it's how the "snap to floor" method in the editor works for example
In my use-case I need to know whether a volume (say an AABB) is empty or not. That's why intersect_shape
would be perfect.
Fair enough. Is there a case for an editor-available API for non-moving intersections?
Not at the present as far as I know, I'd say if there was it'd be in there
The question here for evaluation and investigation is what ways the current system handles this, and what would be needed to add this, for example the use of the BSP system and space processing, this isn't cheap though, and would be largely limited in use, so it's not necessarily worth it generally
I will dig into the physics of the editor when I find the time and see how it accomplishes this feature
Edit:
One thing you can do to accomplish a lot of intersection features, with some trickery as well, is using culling in the rendering server, this is used in some editor plugins as far as I can tell (it even says: This function is primarily intended for editor usage. For in-game use cases, prefer physics collision.
, so probably the appropriate solution, do test and see)
The functions that AThousandShips linked are basically the API to query the visual rendering scenario for its spatial info.
E.g. what visuals with a position are inside some convex plane shape, what intersects with a raycast. Not using the physics engine that only has information about physics shapes, but the rendering that only has information about visual geometry and other render objects like lights.
With the ids returned those ids can be used with the ObjectDB / GlobalScope.instance_from_id () to get the actual SceneTree object behind that id, e.g. the node.
It is not something that should be done at runtime, hence the "Use physics for in-game" hint, because it forces stalls and updates on the RenderingServer. For inside the Editor that performance is not much of a concern as long as you do not fire those functions every single frame like mad.
Thanks for that info. I will look into it. Perhaps we could add something like what smix8 and AThousandShips just posted to the docs so that other plugin devs don't take the wrong turn into state.intersect_etc.
I have run into a problem with instances_cull_aabb
— should I open a new issue, or continue here?
ETA - new issue here: https://github.com/godotengine/godot/issues/87709
I have run into a problem with
instances_cull_aabb
— should I open a new issue, or continue here?
If it's a bug, please open an issue on the main Godot repository. See also https://github.com/godotengine/godot/issues/39197.
Describe the project you are working on
Advised to open a proposal here by https://github.com/godotengine/godot/issues/87429#issuecomment-1908761733 Hope I did it right (this time!)
Overview
Can we have a conversation about support for "intersect_X" in editor plugins?
For example, in my "Dabber" plugin, I need to send rays down to mesh surfaces to pick points where I will place a transform to go into a multimesh. I need to know where other things are before I place a new thing. In Related to https://github.com/godotengine/godot-proposals/issues/7811 I asked about whether Godot has an API for spacial queries (in plugins). I only realized recently that the
state.intersect_shape()
method is pretty much already that; hence my bewilderment at it not working in the editor.Describe the problem or limitation you are having in your project
I wish to use the
intersects
functions in thePhysicsDirectSpaceState3D
class while in a plugin/toolintersect_shape()
which currently does not work.intersect_ray()
which does work but I am now not at all sure it's even supposed to, nor how long it will.Examples of use
What use is terrain if one cannot populate it? The reality is that some physics needs to be accessible from Godot plugins.
Physics is disabled in the editor
Quote from @smix8 at https://github.com/godotengine/godot/issues/87429#issuecomment-1908754228
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Replying to some of that quote
@smix8
What if a plugin could have a "Go" button which then:
So it need not be on all the time; only while doing a user-initiated job.
@smix8
Picture this:
Now, please explain how with trig and Geometry3D you can distribute points across all of that such that:
And that's just to start. I do not believe that it's as simple as the quoted. And, if it is, why can that not be wrapped in an API and made available to users of Godot?
Also, what is the difference between this "simple" approach and what Godot physics is already doing?
Paths to progress
Thanks.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
I have nothing for this section
If this enhancement will not be used often, can it be worked around with a few lines of script?
It seems not. The Editor seems to be the nub of the problem.
Is there a reason why this should be core and not an add-on in the asset library?
I am not qualified to know.