Skip to content

Some userdata variables are still uint32_t #1014

Answered by jrouwe
SSNTails asked this question in Q&A
Discussion options

You must be logged in to vote

The sub shape ID points to the leaf shape (which does have a uint64 user data, so if you're not sharing then you can use that), but you can traverse the entire hierarchy of shapes from the body to the leaf shape by writing a recursive function like:

void visit(const Shape *inShape, const SubShapeID &inSubShapeID)
{
	// do something with inShape->GetUserData()
	// ...
	
	switch (inShape->GetType())
	{
	case EShapeType::Decorated:
		// Recurse
		visit(static_cast<const DecoratedShape *>(inShape)->GetInnerShape(), inSubShapeID);
		break;

	case EShapeType::Compound:
	{
		const CompoundShape *compound = static_cast<const CompoundShape *>(inShape);
		
		// Decode sub shape index
		SubShapeID r…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@jrouwe
Comment options

Answer selected by SSNTails
@SSNTails
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1012 on March 27, 2024 20:15.