It was difficult to notice, but we weren't making use of the `USDPrimReader::valid()` API calls during import. In many(all?) cases this was fine as we would check the validity during `read_object_data` or similar anyhow. Rather than just removing the API entirely, this patch attempts to use it and has the following design: - Where ever and whenever a reader is created, in addition to checking null, we should now also check for `valid()` This happens in `usd_capi_import` and `usd_reader_stage`. - The `valid()` call is intended to check just the USD object status. Blender object checks are handled elsewhere (same as they are currently) since these objects are often not available at the time of the call to `valid()` This has the benefit that we at least know that USD is valid before our heavy reading code ever starts executing. Some duplicate checks are now removed. Pull Request: https://projects.blender.org/blender/blender/pulls/129181
53 lines
1.4 KiB
C++
53 lines
1.4 KiB
C++
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
#pragma once
|
|
|
|
#include "usd_reader_xform.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 USDXformReader {
|
|
private:
|
|
pxr::UsdGeomPointInstancer point_instancer_prim_;
|
|
|
|
public:
|
|
USDPointInstancerReader(const pxr::UsdPrim &prim,
|
|
const USDImportParams &import_params,
|
|
const ImportSettings &settings)
|
|
: USDXformReader(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;
|
|
|
|
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);
|
|
};
|
|
|
|
} // namespace blender::io::usd
|