USD Exporter Error: metersPerUnit does not match retrieved type float #90519

Closed
opened 2021-08-08 15:44:07 +02:00 by Dan McLaughlin · 12 comments

System Information
Operating system: Window 10
Graphics card: Titan

Blender Version
Broken: 2.93

Short description of error
Verified the error on importing into two application, Unreal 5 and Nvidia Metaverse View, both of which report the same problem that metersPerUnit has a requested type of double, but the retrieved value is float.

Exact steps for others to reproduce the error
Export a USDC file, settings don't seem to matter (and shouldn't)
Import into another program

**System Information** Operating system: Window 10 Graphics card: Titan **Blender Version** Broken: 2.93 **Short description of error** Verified the error on importing into two application, Unreal 5 and Nvidia Metaverse View, both of which report the same problem that metersPerUnit has a requested type of double, but the retrieved value is float. **Exact steps for others to reproduce the error** Export a USDC file, settings don't seem to matter (and shouldn't) Import into another program
Author

Added subscriber: @DrMc

Added subscriber: @DrMc

Added subscribers: @makowalski, @mano-wii

Added subscribers: @makowalski, @mano-wii

I couldn't investigate the issue as I don't have Unreal 5 or Nvidia Metaverse View to test.

@makowalski, if I'm not mistaken, you worked on that exporter, right?
Any idea what this metersPerUnit warning is?

I couldn't investigate the issue as I don't have `Unreal 5` or `Nvidia Metaverse View` to test. @makowalski, if I'm not mistaken, you worked on that exporter, right? Any idea what this `metersPerUnit` warning is?
Author

I would guess any application that imports USD would notice it, basically the Blender file is saying one thing but doing another, it's probably as simple as changing the variable type actually being exported.

I believe meters per unit it nothing more than ordinary scene scale. E.g. the data is stored with dimensionless units, and metersPerUnit tells you how to interpret it. Unreal has an option to set it.

image.png

I would guess any application that imports USD would notice it, basically the Blender file is saying one thing but doing another, it's probably as simple as changing the variable type actually being exported. I believe meters per unit it nothing more than ordinary scene scale. E.g. the data is stored with dimensionless units, and metersPerUnit tells you how to interpret it. Unreal has an option to set it. ![image.png](https://archive.blender.org/developer/F10275181/image.png)

@mano-wii My apologies for the delayed reply. I actually worked on the USD importer, not the exporter. However, looking at the code, I confirmed that @DrMc is correct: there is a small error in the code that is setting the metersPerUnit value to a float instead of the expected double. It should be a very easy fix in the Blender USD exporter code.

@mano-wii My apologies for the delayed reply. I actually worked on the USD importer, not the exporter. However, looking at the code, I confirmed that @DrMc is correct: there is a small error in the code that is setting the `metersPerUnit` value to a `float` instead of the expected `double`. It should be a very easy fix in the Blender USD exporter code.

Indeed, it seems that a simple cast like the following (in usd_capi_export.cc, line 104) fixes the warning:

usd_stage->SetMetadata(pxr::UsdGeomTokens->metersPerUnit,
                       static_cast<double>(scene->unit.scale_length));
Indeed, it seems that a simple cast like the following (in usd_capi_export.cc, line 104) fixes the warning: ``` usd_stage->SetMetadata(pxr::UsdGeomTokens->metersPerUnit, static_cast<double>(scene->unit.scale_length)); ```
Author

Just a note @makowalski that it's actually an error not a warning, for both applications it fails to load the Blender export due to this.

Just a note @makowalski that it's actually an error not a warning, for both applications it fails to load the Blender export due to this.

Added subscriber: @dr.sybren

Added subscriber: @dr.sybren

In #90519#1204632, @makowalski wrote:
Indeed, it seems that a simple cast like the following (in usd_capi_export.cc, line 104) fixes the warning:

usd_stage->SetMetadata(pxr::UsdGeomTokens->metersPerUnit,
                       static_cast<double>(scene->unit.scale_length));

It seems like a simple and safe change.
I wouldn't mind committing, but the code was introduced in ec62413f80.
So, @dr.sybren, would you mind taking a look?

> In #90519#1204632, @makowalski wrote: > Indeed, it seems that a simple cast like the following (in usd_capi_export.cc, line 104) fixes the warning: > > ``` > usd_stage->SetMetadata(pxr::UsdGeomTokens->metersPerUnit, > static_cast<double>(scene->unit.scale_length)); > ``` It seems like a simple and safe change. I wouldn't mind committing, but the code was introduced in ec62413f80. So, @dr.sybren, would you mind taking a look?

LGTM, @mano-wii by all means commit the fix.

LGTM, @mano-wii by all means commit the fix.

This issue was referenced by bbcb60fb22

This issue was referenced by bbcb60fb22b375094836e4ab90569db1f73c42e3

Changed status from 'Needs Triage' to: 'Resolved'

Changed status from 'Needs Triage' to: 'Resolved'
Germano Cavalcante self-assigned this 2021-08-11 14:42:48 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#90519
No description provided.