14#define DNA_DEPRECATED_ALLOW
31using Alembic::AbcGeom::CameraSample;
32using Alembic::AbcGeom::ICamera;
33using Alembic::AbcGeom::ICompoundProperty;
34using Alembic::AbcGeom::IFloatProperty;
35using Alembic::AbcGeom::ISampleSelector;
36using Alembic::AbcGeom::kWrapExisting;
38namespace io::alembic {
42 ICamera abc_cam(
m_iobject, kWrapExisting);
43 m_schema = abc_cam.getSchema();
48 return m_schema.valid();
52 const Alembic::AbcCoreAbstract::ObjectHeader &alembic_header,
54 const char **r_err_str)
const
56 if (!Alembic::AbcGeom::ICamera::matches(alembic_header)) {
58 "Object type mismatch, Alembic object path pointed to Camera when importing, but not any "
64 *r_err_str =
RPT_(
"Object type mismatch, Alembic object path points to Camera");
72 const ICamera::schema_type &schema,
73 const ISampleSelector &sample_sel)
75 CameraSample cam_sample;
76 schema.get(cam_sample, sample_sel);
78 ICompoundProperty customDataContainer = schema.getUserProperties();
80 if (customDataContainer.valid() && customDataContainer.getPropertyHeader(
"stereoDistance") &&
81 customDataContainer.getPropertyHeader(
"eyeSeparation"))
83 IFloatProperty convergence_plane(customDataContainer,
"stereoDistance");
84 IFloatProperty eye_separation(customDataContainer,
"eyeSeparation");
86 bcam->stereo.interocular_distance = eye_separation.getValue(sample_sel);
87 bcam->stereo.convergence_distance = convergence_plane.getValue(sample_sel);
90 const float lens =
float(cam_sample.getFocalLength());
91 const float apperture_x =
float(cam_sample.getHorizontalAperture());
92 const float apperture_y =
float(cam_sample.getVerticalAperture());
93 const float h_film_offset =
float(cam_sample.getHorizontalFilmOffset());
94 const float v_film_offset =
float(cam_sample.getVerticalFilmOffset());
95 const float film_aspect = apperture_x / apperture_y;
98 bcam->sensor_x = apperture_x * 10;
99 bcam->sensor_y = apperture_y * 10;
100 bcam->shiftx = h_film_offset / apperture_x;
101 bcam->shifty = v_film_offset / apperture_y / film_aspect;
102 bcam->clip_start =
max_ff(0.1f,
float(cam_sample.getNearClippingPlane()));
103 bcam->clip_end =
float(cam_sample.getFarClippingPlane());
104 bcam->dof.focus_distance =
float(cam_sample.getFocusDistance());
105 bcam->dof.aperture_fstop =
float(cam_sample.getFStop());
118#define ENUMERATE_CAMERA_PROPERTIES(X) \
119 X(lens, lens, lens) \
120 X(sensor_width, sensor_width, sensor_x) \
121 X(sensor_height, sensor_height, sensor_y) \
122 X(clip_start, clip_start, clip_start) \
123 X(clip_end, clip_end, clip_end) \
124 X(shift_x, shift_x, shiftx) \
125 X(shift_y, shift_y, shifty) \
126 X(focus_distance, dof.focus_distance, dof.focus_distance) \
127 X(aperture_fstop, dof.aperture_fstop, dof.aperture_fstop) \
128 X(interocular_distance, stereo.interocular_distance, stereo.interocular_distance) \
129 X(convergence_distance, stereo.convergence_distance, stereo.convergence_distance)
132 Camera *camera_ =
nullptr;
133 const Alembic::AbcGeom::ICameraSchema &schema_{};
137 struct MemberModified {
138#define DECLARE_MEMBER(short_name, rna_path, member_accessor) bool short_name = false;
143 MemberModified member_modified_{};
145#define DECLARE_FCURVES(short_name, rna_path, member_accessor) \
146 FCurve *short_name##_fcurve = nullptr;
148#undef DECLARE_FCURVES
158#define CREATE_FCURVE(short_name, rna_path, member_accessor) \
159 short_name##_fcurve = create_fcurve({#rna_path, 0}, sample_count);
167 Camera last_camera = *camera_;
170#define SET_FCURVE_SAMPLE(short_name, rna_path, member_accessor) \
171 set_fcurve_sample(short_name##_fcurve, \
172 sample_info.sample_index, \
174 camera_->member_accessor); \
175 member_modified_.short_name |= last_camera.member_accessor != camera_->member_accessor;
177#undef SET_FCURVE_SAMPLE
182#define REMOVE_UNNECESSARY_FCURVE(short_name, rna_path, member_accessor) \
183 if (member_modified_.short_name == false) { \
184 channelbag->fcurve_remove(*short_name##_fcurve); \
187#undef REMOVE_UNNECESSARY_FCURVE
193 if (m_schema.isConstant()) {
198 return std::make_unique<CameraFCurveCreationHelper>(
camera, m_schema);
Functions and classes to work with Actions.
Functions to modify FCurves.
Camera data-block and utility functions.
General operations, lookup, etc. for blender objects.
Object is a sort of wrapper for general info.
#define REMOVE_UNNECESSARY_FCURVE(short_name, rna_path, member_accessor)
#define DECLARE_MEMBER(short_name, rna_path, member_accessor)
#define SET_FCURVE_SAMPLE(short_name, rna_path, member_accessor)
#define DECLARE_FCURVES(short_name, rna_path, member_accessor)
#define CREATE_FCURVE(short_name, rna_path, member_accessor)
#define ENUMERATE_CAMERA_PROPERTIES(X)
bool accepts_object_type(const Alembic::AbcCoreAbstract::ObjectHeader &alembic_header, const Object *const ob, const char **r_err_str) const override
AbcCameraReader(const AbcReaderConstructorArgs &args)
std::unique_ptr< FCurveCreationHelper > getKeyFramingHelper() override
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel) override
bool valid() const override
std::string m_object_name
Alembic::Abc::IObject m_iobject
AbcObjectReader(const AbcReaderConstructorArgs &args)
void set_fcurves_sample(const FrameSampleInfo &sample_info) override
void create_fcurves(const int sample_count) override
void remove_unnecessary_fcurves() override
CameraFCurveCreationHelper(Camera *camera, const Alembic::AbcGeom::ICameraSchema &schema)
FCurveCreationHelper(ID *id)
void camera(KernelGlobals &kg, const ShadingData &sd, float3 &outview, float &outdepth, float &outdist)
static void read_camera_sample(Camera *bcam, const ICamera::schema_type &schema, const ISampleSelector &sample_sel)
struct Camera * BKE_camera_add(struct Main *bmain, const char *name)
MINLINE float max_ff(float a, float b)
Object * BKE_object_add_only_object(Main *bmain, ObjectType type, const char *name) ATTR_RETURNS_NONNULL
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
Alembic::Abc::ISampleSelector selector