40 const char **r_err_str)
42 if (!fread(pc2_head,
sizeof(*pc2_head), 1, fp)) {
43 *r_err_str =
RPT_(
"Missing header");
48 *r_err_str =
RPT_(
"Invalid header");
57 *r_err_str =
RPT_(
"Vertex count mismatch");
62 *r_err_str =
RPT_(
"Invalid frame total");
81 const char **r_err_str)
101 const char **r_err_str)
115 else if (frame < 0.0f) {
124 float (*vertexCos)[3],
128 const char **r_err_str)
137 *r_err_str =
RPT_(
"Failed to seek frame");
141 size_t verts_read_num = 0;
143 if (factor >= 1.0f) {
144 float *vco = *vertexCos;
147 verts_read_num += fread(vco,
sizeof(
float[3]), 1, fp);
154 const float ifactor = 1.0f - factor;
155 float *vco = *vertexCos;
159 verts_read_num += fread(tvec,
sizeof(
float[3]), 1, fp);
164 vco[0] = (vco[0] * ifactor) + (tvec[0] * factor);
165 vco[1] = (vco[1] * ifactor) + (tvec[1] * factor);
166 vco[2] = (vco[2] * ifactor) + (tvec[2] * factor);
170 if (verts_read_num != pc2_head.
verts_tot) {
171 *r_err_str = errno ? strerror(errno) :
RPT_(
"Vertex coordinate read failed");
179 float (*vertexCos)[3],
183 const char **r_err_str)
199 if (index_range[0] == index_range[1]) {
223 float (*vertexCos)[3],
228 const char time_mode,
229 const char **r_err_str)
237 *r_err_str = errno ? strerror(errno) :
RPT_(
"Unknown error opening file");
File and directory operations.
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)
Compatibility-like things for windows.
@ MOD_MESHCACHE_TIME_FRAME
@ MOD_MESHCACHE_TIME_FACTOR
@ MOD_MESHCACHE_TIME_SECONDS
static bool meshcache_read_pc2_head(FILE *fp, const int verts_tot, PC2Head *pc2_head, 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_index(FILE *fp, float(*vertexCos)[3], const int verts_tot, const int index, const float factor, 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)
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)
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)
void MOD_meshcache_calc_range(const float frame, const char interp, const int frame_tot, int r_index_range[2], float *r_factor)
ccl_device_inline float interp(const float a, const float b, const float t)