Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/instance-feature-metadata' into …
Browse files Browse the repository at this point in the history
…instance-feature-rendering
  • Loading branch information
kring committed Dec 20, 2024
2 parents e9426b9 + 8db3e82 commit 5698537
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 40 deletions.
10 changes: 1 addition & 9 deletions Source/CesiumRuntime/Private/CesiumFeatureIdSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ FCesiumFeatureIdSet::FCesiumFeatureIdSet(
// For backwards compatibility with GetFeatureTableName.
const CesiumGltf::ExtensionModelExtStructuralMetadata* pMetadata =
InModel.getExtension<CesiumGltf::ExtensionModelExtStructuralMetadata>();
if (pMetadata && _propertyTableIndex >= 0) {
if (pMetadata && this->_propertyTableIndex >= 0) {
size_t index = static_cast<size_t>(_propertyTableIndex);
if (index < pMetadata->propertyTables.size()) {
const CesiumGltf::PropertyTable& propertyTable =
Expand Down Expand Up @@ -174,14 +174,6 @@ int64 UCesiumFeatureIdSetBlueprintLibrary::GetFeatureIDForVertex(
return -1;
}

namespace {
struct FeatureIdFromAccessorView : public CesiumGltf::FeatureIdFromAccessor {
FeatureIdFromAccessorView(int64_t index_) { index = index_; }

int64_t operator()(std::monostate) { return -1; }
};
} // namespace

int64 UCesiumFeatureIdSetBlueprintLibrary::GetFeatureIDForInstance(
UPARAM(ref) const FCesiumFeatureIdSet& FeatureIDSet,
int64 InstanceIndex) {
Expand Down
4 changes: 2 additions & 2 deletions Source/CesiumRuntime/Private/CesiumGltfComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2039,7 +2039,7 @@ static void loadInstancingData(
}
if (pInstanceFeatures) {
result.pInstanceFeatures =
MakeShared<FCesiumPrimitiveFeatures>(model, node);
MakeShared<FCesiumPrimitiveFeatures>(model, node, *pInstanceFeatures);
}
}

Expand Down Expand Up @@ -2928,7 +2928,7 @@ static void loadPrimitiveGameThreadPart(
bool createNavCollision,
ACesium3DTileset* pTilesetActor,
const std::vector<FTransform>& instanceTransforms,
TSharedPtr<FCesiumPrimitiveFeatures> pInstanceFeatures) {
const TSharedPtr<FCesiumPrimitiveFeatures>& pInstanceFeatures) {
TRACE_CPUPROFILER_EVENT_SCOPE(Cesium::LoadPrimitive)

#if DEBUG_GLTF_ASSET_NAMES
Expand Down
15 changes: 4 additions & 11 deletions Source/CesiumRuntime/Private/CesiumPrimitiveFeatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,14 @@ FCesiumPrimitiveFeatures::FCesiumPrimitiveFeatures(

FCesiumPrimitiveFeatures::FCesiumPrimitiveFeatures(
const CesiumGltf::Model& Model,
const CesiumGltf::Node& Node)
const CesiumGltf::Node& Node,
const CesiumGltf::ExtensionExtInstanceFeatures& InstanceFeatures)
: _vertexCount(0), _primitiveMode(-1) {
if (Node.mesh < 0 || Node.mesh >= Model.meshes.size()) {
return;
}
const auto* pInstancing =
Node.getExtension<CesiumGltf::ExtensionExtMeshGpuInstancing>();
if (!pInstancing) {
return;
}
if (const auto* pInstanceFeatures =
Node.getExtension<CesiumGltf::ExtensionExtInstanceFeatures>()) {
for (const auto& featureId : pInstanceFeatures->featureIds) {
_featureIdSets.Emplace(Model, Node, featureId);
}
for (const auto& featureId : InstanceFeatures.featureIds) {
this->_featureIdSets.Emplace(Model, Node, featureId);
}
}

Expand Down
18 changes: 3 additions & 15 deletions Source/CesiumRuntime/Private/LoadGltfResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,8 @@ struct LoadMeshResult {
LoadMeshResult() {}

LoadMeshResult(const LoadMeshResult&) = delete;

LoadMeshResult(LoadMeshResult&& other) {
primitiveResults.swap(other.primitiveResults);
}

LoadMeshResult& operator=(LoadMeshResult&& other) {
primitiveResults.swap(other.primitiveResults);
return *this;
}
LoadMeshResult(LoadMeshResult&& other) = default;
LoadMeshResult& operator=(LoadMeshResult&& other) = default;

std::vector<LoadPrimitiveResult> primitiveResults{};
};
Expand All @@ -182,12 +175,7 @@ struct LoadNodeResult {
LoadNodeResult() {}

LoadNodeResult(const LoadNodeResult&) = delete;

LoadNodeResult(LoadNodeResult&& other)
: pInstanceFeatures(std::move(other.pInstanceFeatures)) {
InstanceTransforms.swap(other.InstanceTransforms);
meshResult.swap(other.meshResult);
}
LoadNodeResult(LoadNodeResult&& other) = default;

std::optional<LoadMeshResult> meshResult = std::nullopt;
/**
Expand Down
9 changes: 6 additions & 3 deletions Source/CesiumRuntime/Public/CesiumPrimitiveFeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace CesiumGltf {
struct ExtensionExtMeshFeatures;
struct ExtensionExtInstanceFeatures;
} // namespace CesiumGltf

/**
Expand All @@ -36,8 +37,7 @@ struct CESIUMRUNTIME_API FCesiumPrimitiveFeatures {
* @param Model The model that contains the EXT_mesh_features extension
* @param Primitive The mesh primitive that stores EXT_mesh_features
* extension
* @param Features The EXT_mesh_features of the glTF mesh primitive.
* primitive
* @param Features The EXT_mesh_features of the glTF mesh primitive
*/
FCesiumPrimitiveFeatures(
const CesiumGltf::Model& Model,
Expand All @@ -50,10 +50,13 @@ struct CESIUMRUNTIME_API FCesiumPrimitiveFeatures {
* @param Model The model that contains the EXT_instance_features extension
* @param Node The node that stores EXT_instance_features
* extension
* @param InstanceFeatures The EXT_Instance_features of the glTF mesh
* primitive
*/
FCesiumPrimitiveFeatures(
const CesiumGltf::Model& Model,
const CesiumGltf::Node& Node);
const CesiumGltf::Node& Node,
const CesiumGltf::ExtensionExtInstanceFeatures& InstanceFeatures);

private:
TArray<FCesiumFeatureIdSet> _featureIdSets;
Expand Down

0 comments on commit 5698537

Please sign in to comment.