-
Notifications
You must be signed in to change notification settings - Fork 11
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
chore: sdk camera control minor iteration #2058
Conversation
WalkthroughThe pull request introduces several changes across multiple files, primarily focusing on enhancing the handling of camera transitions and the management of virtual camera entities. Key modifications include the restructuring of transition logic using switch statements, the removal of unnecessary fields from the Changes
Possibly related PRs
Suggested labels
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Windows and Mac build successfull in Unity Cloud! You can find a link to the downloadable artifact below.
|
TODO: after protocol PR gets merged, update the package used by this branch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range and nitpick comments (2)
scripts/package.json (1)
19-19
: Consider the implications of switching to a tarball URL for the@dcl/protocol
dependency.Changing the dependency from a semantic version string to a fixed tarball URL has a few implications:
It ensures that the exact same code is used every time, regardless of any updates to the package on the registry. This can help maintain consistency but also means manually updating the URL for any desired changes.
Fetching the dependency from a CDN URL could impact build times and reliability, as it introduces a dependency on an external service.
The tarball URL doesn't specify a hash, which means there's no guarantee of content integrity. If the content at the URL changes, it could lead to unexpected behavior.
Recommendations:
- Consider adding a hash to the URL for content integrity verification.
- Document the rationale behind this change, including any benefits it provides and any additional considerations for maintainers.
Explorer/Assets/Protocol/DecentralandProtocol/CameraTransition.gen.cs (1)
42-45
: Informative summary comment.The summary comment provides useful context about the potential future updates to the
CameraTransition
class, such as adding support for easing functions and entity specifications. This helps developers understand the broader context and anticipate future changes.Consider creating separate GitHub issues or tracking tasks for the mentioned future updates to ensure they are properly planned and implemented when the time comes.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
scripts/package-lock.json
is excluded by!**/package-lock.json
Files selected for processing (6)
- Explorer/Assets/DCL/SDKComponents/CameraControl/MainCamera/Systems/MainCameraSystem.cs (1 hunks)
- Explorer/Assets/DCL/SDKComponents/CameraControl/MainCamera/VirtualCameraUtils.cs (1 hunks)
- Explorer/Assets/Protocol/DecentralandProtocol/CameraTransition.gen.cs (8 hunks)
- Explorer/Assets/Protocol/DecentralandProtocol/MainCamera.gen.cs (9 hunks)
- Explorer/Assets/Protocol/DecentralandProtocol/VirtualCamera.gen.cs (2 hunks)
- scripts/package.json (1 hunks)
Additional context used
Path-based instructions (5)
Explorer/Assets/DCL/SDKComponents/CameraControl/MainCamera/VirtualCameraUtils.cs (2)
Pattern
**/*.cs
: Review the code for heap allocations and suggest potential improvements to avoid runtime allocations.
Pattern
**/*.cs
: Review the code for specific unity engine optimizations and suggest potential improvements.Explorer/Assets/DCL/SDKComponents/CameraControl/MainCamera/Systems/MainCameraSystem.cs (2)
Pattern
**/*.cs
: Review the code for heap allocations and suggest potential improvements to avoid runtime allocations.
Pattern
**/*.cs
: Review the code for specific unity engine optimizations and suggest potential improvements.Explorer/Assets/Protocol/DecentralandProtocol/MainCamera.gen.cs (2)
Pattern
**/*.cs
: Review the code for heap allocations and suggest potential improvements to avoid runtime allocations.
Pattern
**/*.cs
: Review the code for specific unity engine optimizations and suggest potential improvements.Explorer/Assets/Protocol/DecentralandProtocol/CameraTransition.gen.cs (2)
Pattern
**/*.cs
: Review the code for heap allocations and suggest potential improvements to avoid runtime allocations.
Pattern
**/*.cs
: Review the code for specific unity engine optimizations and suggest potential improvements.Explorer/Assets/Protocol/DecentralandProtocol/VirtualCamera.gen.cs (2)
Pattern
**/*.cs
: Review the code for heap allocations and suggest potential improvements to avoid runtime allocations.
Pattern
**/*.cs
: Review the code for specific unity engine optimizations and suggest potential improvements.
Additional comments not posted (11)
Explorer/Assets/DCL/SDKComponents/CameraControl/MainCamera/VirtualCameraUtils.cs (1)
45-78
: LGTM!The code changes in the
ConfigureVirtualCameraTransition
method are well-structured and follow a clear logic for handling different transition modes. The code correctly sets the blend style and time based on the transition mode and handles the case when the default transition is null. The code is readable and maintainable.Explorer/Assets/DCL/SDKComponents/CameraControl/MainCamera/Systems/MainCameraSystem.cs (1)
66-66
: LGTM!The change improves the clarity of the condition by explicitly indicating whether a virtual camera entity exists, rather than relying on a numeric comparison. The logic remains correct.
Explorer/Assets/Protocol/DecentralandProtocol/MainCamera.gen.cs (4)
53-53
: Good use of bitfield for tracking optional fields.Using a bitfield
_hasBits0
to track whether optional fields likeVirtualCameraEntity
have been set is a good optimization technique to minimize memory usage. Sinceint
is a value type, it will not cause any heap allocations.
101-117
: Proper handling of optional fields using the bitfield.The updates to the
VirtualCameraEntity
property getter to return0
when the_hasBits0
bitfield indicates the field has not been set is a good practice to avoid returning uninitialized data.The new
HasVirtualCameraEntity()
andClearVirtualCameraEntity()
methods provide a clean way to check the presence of the field and reset it by leveraging the bitfield.These changes efficiently manage the optional field without introducing any new heap allocations or negatively impacting performance.
143-143
: Proper handling of optional fields in hash computation.Updating the
GetHashCode()
method to include theVirtualCameraEntity
field in the hash computation only when the_hasBits0
bitfield indicates it has been set is a good practice.This ensures that two instances of
PBMainCamera
with unsetVirtualCameraEntity
fields will have the same hash code, maintaining consistency.The change does not introduce any performance issues or allocations.
Line range hint
162-166
: Efficient serialization and merging of optional fields.The updates to the
WriteTo()
,InternalWriteTo()
,CalculateSize()
, andMergeFrom()
methods to check the_hasBits0
bitfield before serializing, deserializing, or merging theVirtualCameraEntity
field are an excellent optimization.By avoiding unnecessary reads and writes when the field is not set, these changes improve performance without introducing any new heap allocations.
Moreover, checking the bitfield ensures that the serialized data accurately represents the state of the object by omitting optional fields that are not set.
Also applies to: 176-180, 190-192, 205-207
Explorer/Assets/Protocol/DecentralandProtocol/CameraTransition.gen.cs (4)
29-31
: LGTM!The updated field numbers for
Time
andSpeed
are consistent with the removal of theFromEntity
andToEntity
fields. This ensures proper serialization of the remaining fields.
35-35
: LGTM!The updated
CameraTransition
class definition, which now includes only theTime
andSpeed
fields, simplifies the class structure and is consistent with the removal of theFromEntity
andToEntity
fields.
Line range hint
99-130
: LGTM!The updates to the
TimeFieldNumber
andSpeedFieldNumber
constants, as well as theTransitionModeOneofCase
enum, are consistent with the changes in the protocol buffer definition. These changes ensure proper serialization and deserialization of theTime
andSpeed
fields.
193-199
: LGTM!The updates to the serialization and deserialization logic for the
Time
andSpeed
fields are consistent with the changes in the protocol buffer definition. The new field numbers, 13 and 21, adhere to the protocol buffer wire format and ensure correct serialization and deserialization of these fields.Also applies to: 211-217, 270-278, 293-301
Explorer/Assets/Protocol/DecentralandProtocol/VirtualCamera.gen.cs (1)
30-34
: LGTM!The changes in the descriptor data and the
GeneratedClrTypeInfo
constructor are auto-generated by the protocol buffer compiler to reflect updates in the protocol definition. They improve clarity regarding default camera transition behavior and serialization of theDefaultTransition
andLookAtEntity
properties.As indicated by the comment at the top of the file, these auto-generated changes should not be manually edited.
Also applies to: 38-38
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I like that you took good care of the case with no mode set on the SDK, something we learned recently with the Input Modifier 😅 Good job 💪
…ore/sdk-camera-control-iteration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…ore/sdk-camera-control-iteration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟢 Reviewed by QA and working as expected, as per the instructions on the PR
20.09.2024_08.28.40_REC.mp4
20.09.2024_08.37.16_REC.mp4
Uploading 20.09.2024_08.34.26_REC.mp4…
Updated protocol and adapted to it.
Related PRs:
Summary by CodeRabbit
New Features
Bug Fixes
CameraTransition
class by removing unused fields, focusing on essential properties.Documentation
Chores
@dcl/protocol
to a fixed reference URL.QA TEST INSTRUCTIONS
pravus.dcl.eth
world for running the test scene (/goto pravus
)Things to test:
Using the Character default camera
Using the SDK Camera 1
Using the SDK Camera 2
Using the SDK Camera 3
Using the SDK Camera 4
Camera Mode Area
-> move inside the CameraModeArea that will force 1st person cam
-> press 'E' to activate any SDK camera (doesn't matter which one)
-> cycle through the cameras until you get back to the character camera
-> confirm that you are again under the effect of the Camera Mode Area
-> get out of the Camera Mode Area and confirm you can control the camera again
-> press 'E' to activate any SDK camera (doesn't matter which one)
-> move the character inside the CameraModeArea
-> cycle through the cameras until you get back to the character camera
-> confirm that you are now under the effect of the Camera Mode Area
-> get out of the Camera Mode Area and confirm you can control the camera again
-> move inside the CameraModeArea that will force 1st person cam
-> press 'E' to activate any SDK camera (doesn't matter which one)
-> move the character outside the Camera Mode Area
-> cycle through the cameras until you get back to the character camera
-> confirm that you free from the effect of the Camera Mode Area and you can control the camera again
-> move inside the CameraModeArea that will force 1st person cam
-> press 'E' to activate any SDK camera (doesn't matter which one)
-> move the character outside the Camera Mode Area
-> move the character inside the Camera Mode Area again
-> cycle through the cameras until you get back to the character camera
-> confirm that you are still under the effect of the Camera Mode Area
-> get out of the Camera Mode Area and confirm you can control the camera again
-> press 'E' to activate any SDK camera (doesn't matter which one)
-> move the character inside the Camera Mode Area
-> move the character outside the Camera Mode Area again
-> cycle through the cameras until you get back to the character camera
-> confirm that you are still free from the effect of the Camera Mode Area
Video reference for testing
SDKCameraControlDemo-NO-CONTROLLABLE-CAM.mp4