Add default Plane shape to USD Importer

Implement the USD Plane Shape for import, mirroring what was done for
the others. See #134138

Additional tests will be added afterwards but a simple test is simply to
import the resulting file:
```python
from pxr import Usd, UsdGeom
stage = Usd.Stage.CreateNew('plane.usd')
xform_prim = UsdGeom.Xform.Define(stage, '/world')
plane_prim = UsdGeom.Plane.Define(stage, '/world/plane')
stage.GetRootLayer().Save()
```

Co-authored-by: Nig3l <nig3lpro@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/134275
This commit is contained in:
Maxime-Cots
2025-02-11 19:56:15 +01:00
committed by Jesse Yurkovich
parent db2610f2e4
commit bbab2aa328
2 changed files with 17 additions and 1 deletions

View File

@@ -20,11 +20,13 @@
#include <pxr/usd/usdGeom/cone.h>
#include <pxr/usd/usdGeom/cube.h>
#include <pxr/usd/usdGeom/cylinder.h>
#include <pxr/usd/usdGeom/plane.h>
#include <pxr/usd/usdGeom/sphere.h>
#include <pxr/usdImaging/usdImaging/capsuleAdapter.h>
#include <pxr/usdImaging/usdImaging/coneAdapter.h>
#include <pxr/usdImaging/usdImaging/cubeAdapter.h>
#include <pxr/usdImaging/usdImaging/cylinderAdapter.h>
#include <pxr/usdImaging/usdImaging/planeAdapter.h>
#include <pxr/usdImaging/usdImaging/sphereAdapter.h>
namespace blender::io::usd {
@@ -117,6 +119,12 @@ bool USDShapeReader::read_mesh_values(double motionSampleTime,
return true;
}
if (prim_.IsA<pxr::UsdGeomPlane>()) {
read_values<pxr::UsdImagingPlaneAdapter>(
motionSampleTime, positions, face_indices, face_counts);
return true;
}
BKE_reportf(reports(),
RPT_ERROR,
"Unhandled Gprim type: %s (%s)",
@@ -300,6 +308,13 @@ bool USDShapeReader::is_time_varying()
return geom.GetRadiusAttr().ValueMightBeTimeVarying();
}
if (prim_.IsA<pxr::UsdGeomPlane>()) {
pxr::UsdGeomPlane geom(prim_);
return (geom.GetWidthAttr().ValueMightBeTimeVarying() ||
geom.GetLengthAttr().ValueMightBeTimeVarying() ||
geom.GetAxisAttr().ValueMightBeTimeVarying());
}
BKE_reportf(reports(),
RPT_ERROR,
"Unhandled Gprim type: %s (%s)",

View File

@@ -30,6 +30,7 @@
#include <pxr/usd/usdGeom/mesh.h>
#include <pxr/usd/usdGeom/metrics.h>
#include <pxr/usd/usdGeom/nurbsCurves.h>
#include <pxr/usd/usdGeom/plane.h>
#include <pxr/usd/usdGeom/pointInstancer.h>
#include <pxr/usd/usdGeom/points.h>
#include <pxr/usd/usdGeom/scope.h>
@@ -222,7 +223,7 @@ bool USDStageReader::is_primitive_prim(const pxr::UsdPrim &prim) const
{
return (prim.IsA<pxr::UsdGeomCapsule>() || prim.IsA<pxr::UsdGeomCylinder>() ||
prim.IsA<pxr::UsdGeomCone>() || prim.IsA<pxr::UsdGeomCube>() ||
prim.IsA<pxr::UsdGeomSphere>());
prim.IsA<pxr::UsdGeomSphere>() || prim.IsA<pxr::UsdGeomPlane>());
}
USDPrimReader *USDStageReader::create_reader_if_allowed(const pxr::UsdPrim &prim)