john-chapman / im3d

Immediate mode rendering and 3d gizmos.
MIT License
1.21k stars 63 forks source link

Use layer ID map for sorted draw lists #40

Closed dwarfcrank closed 4 years ago

dwarfcrank commented 4 years ago

The layer IDs were not set correctly when constructing draw lists from sorted primitives, so using gizmos in different layers did not work:

// in the main loop
Im3d::PushLayerId("gizmoLayer");
Im3d::Gizmo("mygizmo", &transform);
Im3d::PopLayerId();

// in the rendering code
if (drawList.m_layerId == Im3d::MakeId("gizmoLayer")) {
    // will never reach here
}

This patch simply sets the layer ID of the draw list from the current index in the ID map.