42 const char **r_err_str)
44 if (!fread(pc2_head,
sizeof(*pc2_head), 1, fp)) {
45 *r_err_str =
RPT_(
"Missing header");
50 *r_err_str =
RPT_(
"Invalid header");
59 *r_err_str =
RPT_(
"Vertex count mismatch");
64 *r_err_str =
RPT_(
"Invalid frame total");
83 const char **r_err_str)
103 const char **r_err_str)
117 else if (frame < 0.0f) {
126 float (*vertexCos)[3],
130 const char **r_err_str)
139 *r_err_str =
RPT_(
"Failed to seek frame");
143 size_t verts_read_num = 0;
145 if (factor >= 1.0f) {
146 float *vco = *vertexCos;
148 for (i = pc2_head.
verts_tot; i != 0; i--, vco += 3) {
149 verts_read_num += fread(vco,
sizeof(
float[3]), 1, fp);
156 const float ifactor = 1.0f - factor;
157 float *vco = *vertexCos;
159 for (i = pc2_head.
verts_tot; i != 0; i--, vco += 3) {
161 verts_read_num += fread(tvec,
sizeof(
float[3]), 1, fp);
166 vco[0] = (vco[0] * ifactor) + (tvec[0] * factor);
167 vco[1] = (vco[1] * ifactor) + (tvec[1] * factor);
168 vco[2] = (vco[2] * ifactor) + (tvec[2] * factor);
172 if (verts_read_num != pc2_head.
verts_tot) {
173 *r_err_str = errno ? strerror(errno) :
RPT_(
"Vertex coordinate read failed");
181 float (*vertexCos)[3],
185 const char **r_err_str)
201 if (index_range[0] == index_range[1]) {
225 float (*vertexCos)[3],
230 const char time_mode,
231 const char **r_err_str)
239 *r_err_str = errno ? strerror(errno) :
RPT_(
"Unknown error opening file");
File and directory operations.
Compatibility-like things for windows.
ccl_device_inline float interp(const float a, const float b, const float t)
bool MOD_meshcache_read_pc2_index(FILE *fp, float(*vertexCos)[3], const int verts_tot, const int index, const float factor, const char **r_err_str)
@ MOD_MESHCACHE_TIME_SECONDS
@ MOD_MESHCACHE_TIME_FACTOR
@ MOD_MESHCACHE_TIME_FRAME
FILE * BLI_fopen(const char *filepath, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
int BLI_fseek(FILE *stream, int64_t offset, int whence)
void MOD_meshcache_calc_range(const float frame, const char interp, const int frame_tot, int r_index_range[2], float *r_factor)
static bool meshcache_read_pc2_head(FILE *fp, const int verts_tot, PC2Head *pc2_head, const char **r_err_str)
bool MOD_meshcache_read_pc2_frame(FILE *fp, float(*vertexCos)[3], const int verts_tot, const char interp, const float frame, const char **r_err_str)
static bool meshcache_read_pc2_range_from_time(FILE *fp, const int verts_tot, const float time, const float fps, float *r_frame, const char **r_err_str)
static bool meshcache_read_pc2_range(FILE *fp, const int verts_tot, const float frame, const char interp, int r_index_range[2], float *r_factor, const char **r_err_str)
bool MOD_meshcache_read_pc2_times(const char *filepath, float(*vertexCos)[3], const int verts_tot, const char interp, const float time, const float fps, const char time_mode, const char **r_err_str)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float