Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instance feature metadata #1537

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Instance feature metadata #1537

wants to merge 7 commits into from

Conversation

timoore
Copy link
Contributor

@timoore timoore commented Oct 30, 2024

Support for accessing metadata in GPU instances in picking hit results.

I thought this was the source of a bug. Not sure about this now, but
it seems good to be explicit about what we mean for the move.
This is needed because
UCesiumFeatureIdSetBlueprintLibrary::GetAsFeatureIDAttribute() returns
an error for instance attributes. I guess that's reasonable behavior.
@kring kring self-assigned this Nov 12, 2024
@kring kring self-requested a review November 12, 2024 04:11
@kring kring removed their assignment Nov 12, 2024
Copy link
Member

@kring kring left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timoore I tried this out with the instanced version of everybody's favorite model, and it works well. In fact, the existing Metadata level in the Samples can now query instanced models without any changes, which is nice!

However, I also found that that commonality with non-instanced metadata pretty much ends there. As soon as you want to use any of the lower-level, more powerful metadata access Blueprint APIs, we're stick with completely different paths for instanced and non-instanced models.

Now there are certainly details here that I don't understand, but I'm reasonably sure that this doesn't need to be so. For example, Get Feature ID From Hit looks to me like a concept that works (and is identical) across all types of models. So why do we now have two functions to do this? (confusingly, they have the same name, too)

Well, the immediate reason is that one needs "Primitive Features" and the other needs "Instance Features". But why are those separate? Both are just containers for sets of feature IDs that are resolved in different ways:

  1. By face -> vertex -> feature ID attribute lookup
  2. By texture coordinate -> feature ID texture lookup
  3. And now! By instance ID -> feature ID lookup

In fact, it seems reasonable that a single "hit" could return feature IDs from all three. There could be metadata attached to the instance, the vertex, and the texture.

What do you think, is that achievable?

So that's my main feedback on this PR. I also have some additional small comments below, based on only a partial review of the code so far.


LoadPrimitiveResult() {}

LoadPrimitiveResult(LoadPrimitiveResult&& other)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this just be LoadPrimitiveResult(LoadPrimitiveResult&& other) = default; ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this myself when I merged in main, because I was too lazy to manually update the move constructor for the incoming modifications. But let me know if there's some reason this was a bad idea.

* default (because of the TUniquePtr usage). Of course we really want to use
* move constructors with all these unique pointers. So, we explicitly write the
* move constructors and delete the copy constructor, in part to document what
* should happen.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to recount the history here. A comment saying "This type is move-only" (above the deleted copy constructor/assignment and defaulted move constructor/assignment) is sufficient.

Comment on lines +161 to +165
const TSharedPtr<FCesiumInstanceFeatures> pInstanceFeatures =
pInstancedComponent->pInstanceFeatures;
if (!pInstanceFeatures) {
return TMap<FString, FCesiumMetadataValue>();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check looks unnecessary. And also redundant because GetInstanceFeatures does the same thing.

@kring kring added this to the December 2024 Release milestone Nov 14, 2024
@j9liu
Copy link
Contributor

j9liu commented Nov 15, 2024

I haven't looked deeply at this PR, but with the way that EXT_instance_features exists on a node versus EXT_mesh_features existing on a primitive, I feel like the separation between the two makes sense.

I also don't see something that disallows EXT_instance_features from instancing a mesh with EXT_mesh_features. I feel like you would need to differentiate between the two. Maybe you have two separate building instances, and you'll want their different instance IDs. But what if you want to get the feature ID of the window within an instance? Then it becomes confusing whether the returned feature ID is from EXT_instance_features or EXT_mesh_features

I feel like it makes more sense if we use "Instance ID" for EXT_instance_features, if that's acceptable terminology. Or if not "Instance ID", then very carefully differentiating the feature IDs of the instances versus the feature IDs in the mesh. Using "Instance ID" as shorthand makes most sense for me, and you could rename the Get Feature ID From Hit with CesiumInstanceFeatures to Get Instance ID From Hit. Does that seem reasonable?

@j9liu
Copy link
Contributor

j9liu commented Nov 15, 2024

Hm now that I think about it, "Instance ID" is not an accurate descriptor / is confusing for cases where you're assigning multiple instances the same feature ID. So maybe we have to use terminology like "Instance Feature ID" vs. "Mesh Feature ID" ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants