CesiumGS / cesium-native

Apache License 2.0
421 stars 212 forks source link

Added `forEachNodeInScene` #884

Closed lilleyse closed 4 months ago

lilleyse commented 4 months ago

I found myself needing a function like forEachPrimitiveInScene but without drilling into meshes / primitives and just traversing over nodes.

kring commented 4 months ago

Thanks @lilleyse! Some of this code is pretty old, written before we had really settled on best practices for integer conversions. So I snuck in some more changes:

if (meshId >= 0 && meshId < static_cast<int32_t>(model.meshes.size()))

Do this:

if (meshId >= 0 && size_t(meshId) < model.meshes.size())

The former could reject valid indices in the (admittedly very unlikely) event that a model has more than 2^31 - 1 meshes.