Files
test2/source/blender/io/usd/intern/usd_reader_pointinstancer.hh
Jesse Yurkovich 2523958e0e USD: Add support for animated point instancers
The existing point instancer reader is slightly refactored to allow for
animated setups. The primary change is simply to inherit from
`USDGeomReader` rather than `USDXformReader`. This allows access to the
`read_geometry` API used by the cache modifier.

The existing `read_object_data` method is split into two parts with
`read_geometry` loading per-frame USD data and `read_object_data`
coordinating the initial loading process, including creating the GN node
tree just once.

A new test has been added (a variation of the nested point instancer
file) with time samples on various attributes and on both point
instancers. This also fixes #129502 and the file provided in that issue.

----
The already added test file is `tests/data/usd/usd_point_instancer_anim.usda`

Pull Request: https://projects.blender.org/blender/blender/pulls/129881
2024-11-20 22:03:32 +01:00

61 lines
1.7 KiB
C++

/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
#include "usd_reader_geom.hh"
#include <pxr/usd/usdGeom/pointInstancer.h>
struct Collection;
namespace blender::io::usd {
/* Wraps the UsdGeomPointInstancer schema. Creates a Blender point cloud object. */
class USDPointInstancerReader : public USDGeomReader {
private:
pxr::UsdGeomPointInstancer point_instancer_prim_;
public:
USDPointInstancerReader(const pxr::UsdPrim &prim,
const USDImportParams &import_params,
const ImportSettings &settings)
: USDGeomReader(prim, import_params, settings), point_instancer_prim_(prim)
{
}
bool valid() const override
{
return bool(point_instancer_prim_);
}
void create_object(Main *bmain, double motionSampleTime) override;
void read_object_data(Main *bmain, double motionSampleTime) override;
/* This may be called by the cache modifier to update animated geometry. */
void read_geometry(bke::GeometrySet &geometry_set,
USDMeshReadParams params,
const char **r_err_str) override;
pxr::SdfPathVector proto_paths() const;
/**
* Set the given collection on the Collection Info
* node referenced by the geometry nodes modifier
* on the object created by the reader. This assumes
* create_object() and read_object_data() have already
* been called.
*
* \param bmain: Pointer to Main
* \param coll: The collection to set
*/
void set_collection(Main *bmain, Collection &coll);
/* Return true if the USD data may be time varying. */
bool is_animated() const;
};
} // namespace blender::io::usd