ramokz / phantom-camera

👻🎥 Control the movement and dynamically tween 2D & 3D cameras. Built for Godot 4. Inspired by Cinemachine.
https://phantom-camera.dev/
MIT License
2.28k stars 77 forks source link

Phantom Camera Host script environment/attributes duplicate() seems rerolling resource IDs in .tscn muddying git commits. #368

Open JelaMiraj opened 3 months ago

JelaMiraj commented 3 months ago

Issue description

I'm using Godot 4.3 dotnet release on windows 11. Everytime I load or save a scene (including caused by just by reopening the project in godot editor) backed by .tscn with my phantom camera setup the random slug ending of the name of the resource id of duplicated camera attributes and environment property nodes get rerolled causing that as a detected change by git. Most likely a result of how lines 598 to 602 of the phantom_camera_host.gd script plays out.

` if _active_pcam_3d.attributes != null: camera_3d.attributes = _active_pcam_3d.attributes.duplicate()

        if _active_pcam_3d.environment != null:
            camera_3d.environment = _active_pcam_3d.environment.duplicate()

` I have 3 phantom cameras wide, main, and close with different priorities and leave the 2 i'm not currently using set to hidden. the scene has just one normal camera3d with the phantomcamerahost node with attached script as a child node.

Hopefully either some workaround that I've yet to find or an actual change in the addon can prevent this issue while preserving need functionality of different camera shots needing different physical camera attribute resources and pbr lighting needing environments...

I have minimal bug demo project options included while we sort this out. Hopefully the solution will be relatively easy to work through! 😻 👍

Steps to reproduce

  1. have a godot project backed by git scm with no pending changes.
  2. Have a scene saved as a .tscn.
  3. add camera3d node.
  4. add phantom camera node.
  5. add environment resource and camera attributes resource to phantom camera node properties. (I chose ones backed by external files).
  6. save scene and the git pending changes to narrow the list later.
  7. attach phantomcamerahost node with its script as a child of camera3d node. (it's first activation will make the random ID's resource in the scene and subseqently brand new ones with new names for git to detect endlessly.)
  8. save or (re)load the .tscn and check git pending changes.
  9. if no randomly renamed environment or camera attributes resource id in .tscn try again save/(re)load the .tscn and check git pending changes.

(Optional) Minimal reproduction project

Reproduction minimal demo project with commits: Linked until I private when I know resolved Attached zip of git repo of min bug demo project at same commit at that time. PhantomCam_TScene_Save_HCam_AttrEnv_Glitch_Example-main.zip

ramokz commented 3 months ago

It's basically like you have deduced, and should be an addon solution rather than something the user has to do.

The addon code basically just needs to update the environment and attribute properties to the Camera3D only on change, rather than duplicating and reassigning the resource every frame. It was purposely written less efficiently like this to get the release and feature out sooner, hence the TODO optimization comment a few lines above the ones you referenced.

It shouldn't cause any issues as the resource ID is specific to the Camera3D node. So the git change can be ignored / reverted for now.

ramokz commented 6 days ago

Got a branch set up that circumvents the .duplicate() approach and also allows for changing the properties during runtime. However, it's currently blocked due to a bug where not all properties emit the changed() signal.

Have submitted an issue, it only covers attributes for now, as I don't want to conflate both attributes and environment resources into one issue.