Skip to content

Fix some general issues with Buoyant Objects (GerstnerWavesJobs.Registry Editor, physics-related)#11

Open
Zallist wants to merge 5 commits intoUnity-Technologies:mainfrom
Zallist:bonuses
Open

Fix some general issues with Buoyant Objects (GerstnerWavesJobs.Registry Editor, physics-related)#11
Zallist wants to merge 5 commits intoUnity-Technologies:mainfrom
Zallist:bonuses

Conversation

@Zallist
Copy link
Copy Markdown

@Zallist Zallist commented Dec 14, 2022

Fixes GerstnerWavesJobs.Registry to clear itself on CleanUp so changing Buoyant Object voxel resolution or buoyancy type doesn't require an Editor restart.

Fixed the following issues in the BuoyantObjectEditor:

  • Inconsistent Foldout usage (using foldout headers rather than one of one and one of the other)
  • Remove the concept of foldouts altogether if not in PLAYING mode, since Height Debug is only visible on PLAYING
  • Make the Heights debug foldout actually openable by storing to the bool for it

Fixed the following issues in BuoyantObject:

  • Explicit property types for IsVoxelBased and IsPhysicsBased so the code's easier to read for the different routes.
  • Only do changes in Update if doing a NonPhysical type of interaction
  • Only do changes in FixedUpdate if doing a Physical type of interaction, which makes the buoyant objects significantly less choppy when the frame rate is different to the fixed time step.
  • Changed the LateUpdate call to a Coroutine-based LateFixedUpdate which runs AFTER the physics cycle has ran, whereas FixedUpdate runs before the physics.
  • Call Physics.SyncTransforms() while slicing into voxels since we're explicitly changing transforms to reset to 0, but need them synced to actually query moved colliders.

…ing the work. Also fixed up the Buoyant editor so it uses consistent foldouts and doesn't show unnecessary stuff in Editor.
Fixes an issue where the array sizes don't match after a hot reload.
… worked as expected if resolutions changed.

Changed BuoyantObject to use a LateFixedUpdate to setup its next Gerstner jobs, since they're only needed for Physics based interactions. Also updated to explicitly reference IsPhysicsBased and IsVoxelBased for code sanity.
public class BuoyantObjectEditor : Editor
{
private BuoyantObject obj;
private BuoyantObject Obj => serializedObject.targetObject as BuoyantObject;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does performance matter in this script? There's some overhead added by using a property getter, plus I'm pretty sure it will do the cast each time this is accessed.

var vec = t.position;
vec.y = Heights[0].y + waterLevelOffset;
t.position = vec;
var up = t.up;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you didn't write the original, but the assignment to up isn't needed. t.up will be evaluated first in the next line before overwriting it. t.up = Vector3.Slerp(t.up, _normals[0], dt)

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

Successfully merging this pull request may close these issues.

2 participants