41 using Alembic::Abc::P3fArraySamplePtr;
42 using Alembic::AbcGeom::OCurves;
43 using Alembic::AbcGeom::OCurvesSchema;
44 using Alembic::AbcGeom::ON3fGeomParam;
45 using Alembic::AbcGeom::OV2fGeomParam;
58 abc_curves_schema_ = abc_curves_.getSchema();
83 std::vector<Imath::V3f>
verts;
84 std::vector<int32_t> hvertices;
85 std::vector<Imath::V2f> uv_values;
86 std::vector<Imath::V3f> norm_values;
97 if (export_children) {
98 write_hair_child_sample(
context,
mesh,
verts, norm_values, uv_values, hvertices);
102 Alembic::Abc::P3fArraySample iPos(
verts);
103 OCurvesSchema::Sample
sample(iPos, hvertices);
104 sample.setBasis(Alembic::AbcGeom::kNoBasis);
105 sample.setType(Alembic::AbcGeom::kLinear);
106 sample.setWrap(Alembic::AbcGeom::kNonPeriodic);
108 if (!uv_values.empty()) {
109 OV2fGeomParam::Sample uv_smp;
110 uv_smp.setVals(uv_values);
114 if (!norm_values.empty()) {
115 ON3fGeomParam::Sample norm_smp;
116 norm_smp.setVals(norm_values);
117 sample.setNormals(norm_smp);
122 abc_curves_schema_.set(
sample);
127 std::vector<Imath::V3f> &
verts,
128 std::vector<Imath::V3f> &norm_values,
129 std::vector<Imath::V2f> &uv_values,
130 std::vector<int32_t> &hvertices)
140 if ((!mtface || !mface) && !uv_warning_shown_) {
142 "Warning, no UV set found for underlying geometry of %s.\n",
144 uv_warning_shown_ =
true;
157 for (
int p = 0; p < psys->
totpart; p++, pa++) {
165 if (num < mesh->totface) {
167 MFace *face = mface ==
nullptr ? nullptr : &mface[num];
168 MTFace *tface = mtface + num;
171 float r_uv[2], mapfw[4], vec[3];
174 uv_values.emplace_back(r_uv[0], r_uv[1]);
177 mverts, face, tface,
nullptr, mapfw, vec,
normal,
nullptr,
nullptr,
nullptr);
180 norm_values.push_back(tmp_nor);
184 std::fprintf(stderr,
"Particle to faces overflow (%d/%d)\n", num,
mesh->
totface);
193 MFace *face = &mface[n];
194 MTFace *tface = mtface + n;
202 for (
int o = 0; o < 4; o++) {
203 if (o > 2 && vtx[o] == 0) {
208 uv_values.emplace_back(tface->
uv[o][0], tface->
uv[o][1]);
214 norm_values.push_back(tmp_nor);
227 hvertices.push_back(
steps);
229 for (k = 0; k <
steps; k++, path++) {
235 verts.emplace_back(vert[0], vert[2], -vert[1]);
240 void ABCHairWriter::write_hair_child_sample(
const HierarchyContext &
context,
242 std::vector<Imath::V3f> &
verts,
243 std::vector<Imath::V3f> &norm_values,
244 std::vector<Imath::V2f> &uv_values,
245 std::vector<int32_t> &hvertices)
261 for (
int p = 0; p < psys->
totchild; p++, pc++) {
265 const int num = pc->
num;
269 "Child particle of hair system %s has unknown face index of geometry of %s, skipping "
277 MTFace *tface = mtface + num;
279 float r_uv[2], tmpnor[3], mapfw[4], vec[3];
282 uv_values.emplace_back(r_uv[0], r_uv[1]);
285 mverts, face, tface,
nullptr, mapfw, vec, tmpnor,
nullptr,
nullptr,
nullptr);
288 norm_values.emplace_back(tmpnor[0], tmpnor[2], -tmpnor[1]);
291 if (!uv_values.empty()) {
292 uv_values.push_back(uv_values[pc->
parent]);
294 if (!norm_values.empty()) {
295 norm_values.push_back(norm_values[pc->
parent]);
300 hvertices.push_back(
steps);
302 for (
int k = 0; k <
steps; k++) {
308 verts.emplace_back(vert[0], vert[2], -vert[1]);
CustomData interface, see also DNA_customdata_types.h.
const CustomData_MeshMasks CD_MASK_MESH
void BKE_mesh_tessface_ensure(struct Mesh *mesh)
struct Mesh * mesh_get_eval_final(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask)
void psys_interpolate_uvs(const struct MTFace *tface, int quad, const float w[4], float uvco[2])
void psys_interpolate_face(struct MVert *mvert, struct MFace *mface, struct MTFace *tface, float(*orcodata)[3], float w[4], float vec[3], float nor[3], float utan[3], float vtan[3], float orco[3])
void mul_m4_v3(const float M[4][4], float r[3])
void invert_m4_m4_safe(float Ainv[4][4], const float A[4][4])
MINLINE void normal_short_to_float_v3(float r[3], const short n[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
#define CLOG_WARN(clg_ref,...)
#define CLOG_INFO(clg_ref, level,...)
struct Scene * DEG_get_evaluated_scene(const struct Depsgraph *graph)
Object is a sort of wrapper for general info.
#define PART_CHILD_PARTICLES
Alembic::Abc::OCompoundProperty abc_schema_prop_for_custom_props(T abc_schema)
uint32_t timesample_index_
Imath::Box3d bounding_box_
const ABCWriterConstructorArgs args_
virtual void update_bounding_box(Object *object)
virtual Alembic::Abc::OObject get_alembic_object() const override
ABCHairWriter(const ABCWriterConstructorArgs &args)
virtual void do_write(HierarchyContext &context) override
virtual bool check_is_animated(const HierarchyContext &context) const override
Alembic::Abc::OCompoundProperty abc_prop_for_custom_props() override
virtual void create_alembic_objects(const HierarchyContext *context) override
IconTextureDrawCall normal
static void sample(SocketReader *reader, int x, int y, float color[4])
BLI_INLINE void copy_yup_from_zup(float yup[3], const float zup[3])
struct SELECTID_Context context
struct ParticleCacheKey ** childcache
struct ParticleCacheKey ** pathcache
Alembic::Abc::OObject abc_parent