void *GodotPrepareRendererResources::prepareInMainThread( Cesium3DTilesSelection::Tile &tile,
void *pLoadThreadResult_ )
{
...
std::vector<MeshInstance3D *> meshInstances;
meshInstances.reserve( meshSize );
for ( int i = 0; i < meshSize; ++i )
{
MeshInstance3D *meshInstance = memnew( MeshInstance3D );
meshInstance->set_name( godot::String( name.c_str() ) );
meshInstance->set_mesh( meshes[i] );
// cesium coordinate axis X is not align godot's, need rotate.
Quaternion qua( Vector3( 1, 0, 0 ), static_cast<real_t>( -Math_PI / 2 ) );
Transform3D trans;
trans.set_basis( qua );
meshInstance->set_transform( trans );
meshInstance->hide();
this->_tileset.add_child( meshInstance );
meshInstance->set_owner( this->_tileset.get_owner() );
meshInstances.push_back( meshInstance );
}
...
}
Cesium3DTileset.cpp
for ( auto pTile : updateResult.tilesToRenderThisFrame )
{
if ( pTile->getState() != TileLoadState::Done )
{
continue;
}
const Cesium3DTilesSelection::TileContent &content = pTile->getContent();
const Cesium3DTilesSelection::TileRenderContent *pRenderContent =
content.getRenderContent();
if ( pRenderContent )
{
CesiumGltfNode *pCesiumGltfNode =
static_cast<CesiumGltfNode *>( pRenderContent->getRenderResources() );
if ( pCesiumGltfNode )
{
for ( MeshInstance3D *instance3d : pCesiumGltfNode->pNodes )
{
instance3d->show();
}
}
}
}
Maybe it's about main thread and work thread issues, godot optimize render many MeshInstance3D nodes, but how to let them render asynchronously.
I'm seeking the answer..