V8 ChangeQueue & Raytraced broken for objects with sub-object materials

The ChangeQueue is not handling objects with sub-object assignments properly in v8 (I am on 8.0.23045.12305). In Raytraced viewport this shows up as these objects not being updated when you move, scale, delete faces, etc, and in the ChangeQueue it shows up as ApplyMeshChanges not being called when you perform these actions.

To demonstrate, just open this 3dm and try to move the cube; it will move dynamically, but then snap back when the move is completed:

sub-object-mat-cq-no-update.3dm (180.6 KB)

This seems related to new behavior discussed in this thread, where we can see that where previously, for a multi-material object, we would get indexed per-face meshes, all with the same mesh ID, in v8 we have no groups, no indexes, and all the meshes have unique IDs.

I have been rewriting my code to deal with this new behavior, but now that I see the ChangeQueue and Raytraced viewport are not dealing with it properly, I am uncertain whether I should continue, before knowing whether the fix will entail further changes to what we are given in the ChangeQueue, or if it is more just a case of ApplyMeshChanges not being called when it should be.

Thank you for the report @jdhill . I’ve logged this as RH-73067 Suboject material problems in the changequeue

seems quite related (split the topic if you prefer), and uses the same example file:

  1. start rhino, open the file provided above, cycles will start rendering
  2. delete the cube
  3. undo

here, you will get: Rhino.Runtime.DocumentCollectedException: ‘Rhino.Geometry.Mesh’

with this stack:

RhinoCommon.dll!Rhino.Runtime.CommonObject.ConstPointer()
RhinoCyclesCore.dll!RhinoCyclesCore.Database.ChangeDatabase.HandleMeshData(System.Guid meshguid, int meshIndex, Rhino.Geometry.Mesh meshdata, Rhino.Render.ChangeQueue.MappingChannelCollection mappingCollection, bool isClippingObject, uint linearlightMatId)
RhinoCyclesCore.dll!RhinoCyclesCore.Database.ChangeDatabase.ApplyMeshChanges(System.Guid[] deleted, System.Collections.Generic.List<Rhino.Render.ChangeQueue.Mesh> added)
RhinoCommon.dll!Rhino.Render.ChangeQueue.ChangeQueue.OnApplyMeshChanges(int serial, System.IntPtr pDeletedUuids, System.IntPtr pAddedMeshes)
...

for a succinct repro, just pop something like this at the top of your ApplyMeshChanges

foreach (var mesh in added)
    Rhino.RhinoApp.WriteLine($"mesh faces: {mesh.GetMeshes().Aggregate(0, (s,m) => s += m?.Faces?.TriangleCount??0 + m?.Faces?.QuadCount??0)}");
1 Like

RH-73067 is fixed in the latest WIP

1 Like