-
Notifications
You must be signed in to change notification settings - Fork 114
DRAFT: broadcast a dynamically-generated mesh #396
base: master
Are you sure you want to change the base?
Conversation
@@ -27,11 +31,42 @@ protected override void WriteRenderer(BinaryWriter message, byte changeType) | |||
if (HasFlag(changeType, MeshFilterChangeType.Mesh)) |
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.
Have you tested whether this flag gets set when someone modifies the meshFilter.mesh on update/start?
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.
No. I have verified that this worked with dynamically-generated meshes in my project, but I didn't take a close look at exactly how the dynamic meshes were created.
I haven't tested changing a mesh after it has already been broadcast and I expect that changes after broadcast would not be detected.
{ | ||
ComponentExtensions.EnsureComponent<MeshRenderer>(gameObject); | ||
MeshFilter filter = ComponentExtensions.EnsureComponent<MeshFilter>(gameObject); | ||
filter.sharedMesh = mesh; |
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.
This may need to be filter.mesh. It looks like filter.sharedMesh isn't suggested for writing meshes.
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.
I find Unity's MeshFilter.mesh/sharedMesh confusing, so I'm not sure. I think the warning about writing is if you modify a mesh using filter.sharedMesh. For example, if you do filter.sharedMesh.vertices = new Vector3[] then you could be inadvertently modifying a mesh that is shared by other objects. In this case, we are not modifying the existing sharedMesh but instead are first creating a Mesh and then assigning that mesh to filter.sharedMesh.
Not sure if I'm making much sense here, but I'm not sure what the right way is to do this or if it even matters which property is used in this case. I expect that assigning to filter.mesh would also be fine.
Thanks for putting this review together. In general this seems like a great starting point. I think there need to be some small changes to reduce the logging for non error states and for cleaning up some todos. I did have a few questions:
|
@chrisfromwork in answer to your specific questions:
|
Thanks for this information. Im going to do some more work on my end to test things out, but ideally we will be able to get this integrated into the repo |
Thanks for doing the extra legwork to test and get this ready for integration, @chrisfromwork! |
This is code that we used in a particular project that I'm sharing here for reference. There might be aspects that should be more generalized before this is made a standard SpectatorView feature, but I don't have time to develop it further.
Potential issues include: