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

Smashing a scaled object appears to re-scale the chunks #6

Open
bshaynes opened this issue Dec 21, 2024 · 6 comments
Open

Smashing a scaled object appears to re-scale the chunks #6

bshaynes opened this issue Dec 21, 2024 · 6 comments

Comments

@bshaynes
Copy link

I'm a little new to Godot but I'm loving this add-on. I'm having an issue with scaling, but maybe I'm doing something wrong.

I imported a set of models that are larger than I'd like for the scene. I scaled down the CollisionShape3D and STMCachedInstance3D to an appropriate size. When I smash_the_mesh, the pieces appear to be scaled down further. Here's a video (the large bench on the right is the original size):

scale-problem.mp4

The same issue happens if you make an object bigger- the chunks are scaled to be even larger than the up-scaled object. I imagine there's some process that's redundantly re-applying transformations to the chunks?

Hierarchy of the objects is fairly simple:
image

I'm aware that I could scale the models before importing, and that would clear this up. But would prefer not to! Again, I'm very new to Godot so I might just be missing something.

@cloudofoz
Copy link
Owner

Hi @bshaynes ,

Thank you for your interest in this addon! You’re right that the scaling logic should be revised. Scaling has always been tricky to manage in this addon, as it significantly impacts the boolean operations required for fracturing the meshes.

In the meantime, thank you for pointing out the details of the issue!

Best regards,
C.

@cloudofoz
Copy link
Owner

stm_scale_test.mp4

I performed a quick test replicating your node hierarchy, scaling the STM-cached instances with three different sizes, and it seems to work without any issues.

Have you tried clearing the cache? You could try fracturing the mesh at its original size, then, after the cache is properly backed up, scale down your mesh. Let me know if this resolves the problem for you, or if not, I may need you to provide the complete test project folder so I can investigate your issue further.

Let me know how it goes!

@bshaynes
Copy link
Author

I attempted that (creating at original size, breaking, resizing) in my scene, and it did not resolve. However, creating a new test scene didn't present any problems when resizing, so it does seem to have something to do with the cache.

@cloudofoz
Copy link
Owner

I'm glad to hear you were able to identify the issue! There are several ways to force a cache refresh that might help resolve your problem:

  1. Disable Cache Reading:
    In the Cache options of STMCachedInstance3D, disable the "Read" option, run the program once, and then re-enable it. This will force the instance to overwrite the cache since it cannot read it.

  2. Manually Delete the Cache File:
    Check the "Name" cache value and manually delete the corresponding file from the cache directory, such as res://stm_cache/[Name].scn. This will force the instance to recreate the cache the next time you run your program.

  3. Change the Cache Name:
    Update the "Name" cache value to something different. For example, if the current name is "123", you could change it to "123_version_2", "123_test", etc. This method is particularly useful if you want to maintain multiple versions of the cache for the same mesh. For example, you could keep both a low-quality and a high-quality version of the fractures.

If none of these options resolve the issue, it could indicate a misconfiguration in your scene or a compatibility issue with some custom code conflicting with the add-on.

Let me know if you have any further questions before I close the issue!

Best wishes,
C.

@bshaynes
Copy link
Author

Well... I tried those three things, and none of them worked.

However, like I mentioned, my example scene works fine. It's actually a stripped-down version of the scene I'm working on. As a test, I ended up copy + pasting everything from the example scene over to my "main" scene except the project.godot file. I now have no issues. I'm not sure what to make of that- is there something in the project settings? Or will it just break again? I'm not sure.

I'm going to work on the scene for a bit and see if it breaks again.

@cloudofoz
Copy link
Owner

It's hard to pinpoint the exact cause without inspecting all the data, but the important thing is that it’s working now! If any issues come up again, feel free to let me know and provide a scene or data that recreates the bug. Otherwise, if the problem doesn’t arise again, you can close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants