godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.59k stars 21.1k forks source link

Curve3D sample_baked ignores parent position and rotation #90188

Open balloonpopper opened 6 months ago

balloonpopper commented 6 months ago

Tested versions

4.3 dev4 (but all versions of v3 and v4 as far as I'm aware)

System information

Windows 10

Issue description

The sample_baked command returns position and rotation values relative to the created path. It ignores the position and orientation of the path. This appears to be a bug to me (when would you want a location on a path in a scene to not give you the location based on where the path is and how it's rotated?)

Steps to reproduce

Create a path3D in a child node. Instance the child node in the parent, and give the node a non zero position and rotation. In the parent, query a position along the path using sample_baked.

Minimal reproduction project (MRP)

PathTest.zip In my scene I have a 2 road tiles (nodes) that are instanced from a parent. One is at the origin and preserves the child nodes original location. The second road tile (node) is offset and rotated. In the parent I create 2 "cars" (a blue and a red CSG cube). Every frame they advance along the path of their respective road tile, and their position is set based on the results from their road's sample_baked output. Instead of each "car" travelling on its respective road tile, both are placed in the exact same coordinates as the sample_baked output isn't relative to the location/rotation of the node they're in (i.e. it's returning local rather than global coordinates and rotation).

smix8 commented 6 months ago

The sample_baked function is not part of the Path3D node that has a transform or a SceneTree representation.

Thesample_baked function is part of a Curve which is a Resource.

A resource has no transform and can be shared and used by many other objects at the same time.

This is not a bug and a resource can not return the position of a node that makes use of the resource. There can be many other objects that do the same at the same time. Also a resource does not care who or what uses it because it is just (or should be) data.

balloonpopper commented 6 months ago

Thanks for the feedback @smix8. It's not intuitive as-is, but at least it makes sense why the position is "wrong" when it's not inheriting a transform.

teopiaz commented 3 weeks ago

IMHO Path3D should return the original curve points and the backed points adjusted for its transform. Otherwise at the moment Path3D is just a container for a Curve3D.