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

Keep base properties when applying references in composition #195

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

rdeioris
Copy link
Contributor

@rdeioris rdeioris commented Oct 20, 2024

While attempting to load the KitchenSet with the Unreal Engine plugin i am working on, i noticed that the references resolving system swallows the base properties.

Example:

def "Refridgerator_1"
                (
                    prepend references = @./assets/Refridgerator/Refridgerator.usd@
                )
                {
                    string HelloWorld = "Hello World"
                    double3 xformOp:translate = (259.9341506958008, 95.84612274169922, -0.5277154445648193)
                    uniform token[] xformOpOrder = ["xformOp:translate"]
                }

By flattening/applying the reference you get:

def Xform "Refridgerator_1"
                (
                    kind = "component"
                    assetInfo = {
                        asset identifier = @assets/Refridgerator/Refridgerator.usd@
                        string name = "Refridgerator"
                    }
                    payload = @./Refridgerator_payload.usd@</Refridgerator>
                    variants = {
                        string modelingVariant = "Decorated"
                    }
                    prepend variantSets = ["modelingVariant"]
                )
                {
              
                }

without the original properties (i have added the HelloWorld one to keep track).

This patch addresses it by re-adding the properties that are not found in the applied reference.

Once applied i was able to correctly get the KitchenSet transforms:

image

@syoyo
Copy link
Collaborator

syoyo commented Oct 20, 2024

Thanks!

Let me give some time to verify/double-check the behavior of 'references' using openUSD.

@syoyo
Copy link
Collaborator

syoyo commented Oct 21, 2024

Confirmed the issue.

input.usda

#usda 1.0

( defaultPrim = "a"

"""
repro scene for https://github.com/lighttransport/tinyusdz/pull/195
Issue 195: base properties(e.g. 'HelloWorld') disappear after `--flatten`.
"""
)

def "a" 
(
    prepend references = @./issue-195-ref.usda@
)
{
    string HelloWorld = "Hello World"
    double3 xformOp:translate = (259.9341506958008, 95.84612274169922, -0.5277154445648193)
    uniform token[] xformOpOrder = ["xformOp:translate"]
}

issue-195-ref.usda

#usda 1.0

( defaultPrim = "a" )

def Xform "a"
(
    kind = "component"
    assetInfo = {
	asset identifier = @assets/Refridgerator/Refridgerator.usd@
	string name = "Refridgerator"
    }
    #payload = @./Refridgerator_payload.usd@</Refridgerator>
    variants = {
	string modelingVariant = "Decorated"
    }
    prepend variantSets = ["modelingVariant"]
)
{

}

Result from openUSD

usdcat --flatten input.usda

#usda 1.0
(
    """
repro scene for https://github.com/lighttransport/tinyusdz/pull/195
Issue 195: base properties(e.g. 'HelloWorld') disappear after `--flatten`.
"""
    defaultPrim = "a"
    doc = """Generated from Composed Stage of root layer /mnt/nvme02/work/tinyusdz/tests/usda/composition/references-prepend-195.usda
"""
)

def Xform "a" (
    assetInfo = {
        asset identifier = @assets/Refridgerator/Refridgerator.usd@
        string name = "Refridgerator"
    }
    kind = "component"
)
{
    string HelloWorld = "Hello World"
    double3 xformOp:translate = (259.9341506958008, 95.84612274169922, -0.5277154445648193)
    uniform token[] xformOpOrder = ["xformOp:translate"]
}

Result from tusdcat

tusdcat --flatten input.usda

#usda 1.0
(
    defaultPrim = "a"
    """
repro scene for https://github.com/lighttransport/tinyusdz/pull/195
Issue 195: base properties(e.g. 'HelloWorld') disappear after `--flatten`.
"""
)

def Xform "a"
(
    kind = "component"
    assetInfo = {
        asset identifier = @assets/Refridgerator/Refridgerator.usd@
        string name = "Refridgerator"
    }
)
{
}

@syoyo syoyo added the bug Something isn't working label Oct 21, 2024
@syoyo
Copy link
Collaborator

syoyo commented Oct 21, 2024

And also confirmed the PR fixes the issue:

With this PR, tusdcat --flatten input.usda gives

#usda 1.0
(
    defaultPrim = "a"
    """
repro scene for https://github.com/lighttransport/tinyusdz/pull/195
Issue 195: base properties(e.g. 'HelloWorld') disappear after `--flatten`.
"""
)

def Xform "a"
(
    kind = "component"
    assetInfo = {
        asset identifier = @assets/Refridgerator/Refridgerator.usd@
        string name = "Refridgerator"
    }
)
{
    double3 xformOp:translate = (259.9341506958008, 95.84612274169922, -0.5277154445648193)
    uniform token[] xformOpOrder = ["xformOp:translate"]
    string HelloWorld = "Hello World"
}

@syoyo syoyo merged commit c9a7815 into lighttransport:dev Oct 21, 2024
14 checks passed
@syoyo
Copy link
Collaborator

syoyo commented Oct 21, 2024

Merged! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants