54 if (!fread(pc2_head,
sizeof(*pc2_head), 1, fp)) {
55 *err_str =
"Missing header";
60 *err_str =
"Invalid header";
66 (
sizeof(*pc2_head) -
sizeof(pc2_head->
header)) /
sizeof(
int));
70 *err_str =
"Vertex count mismatch";
75 *err_str =
"Invalid frame total";
114 const char **err_str)
128 else if (frame < 0.0f) {
137 float (*vertexCos)[3],
141 const char **err_str)
150 *err_str =
"Failed to seek frame";
154 size_t num_verts_read = 0;
156 if (factor >= 1.0f) {
157 float *vco = *vertexCos;
159 for (i = pc2_head.
verts_tot; i != 0; i--, vco += 3) {
160 num_verts_read += fread(vco,
sizeof(
float[3]), 1, fp);
162 #ifdef __BIG_ENDIAN__
170 const float ifactor = 1.0f - factor;
171 float *vco = *vertexCos;
173 for (i = pc2_head.
verts_tot; i != 0; i--, vco += 3) {
175 num_verts_read += fread(tvec,
sizeof(
float[3]), 1, fp);
177 #ifdef __BIG_ENDIAN__
183 vco[0] = (vco[0] * ifactor) + (tvec[0] * factor);
184 vco[1] = (vco[1] * ifactor) + (tvec[1] * factor);
185 vco[2] = (vco[2] * ifactor) + (tvec[2] * factor);
189 if (num_verts_read != pc2_head.
verts_tot) {
190 *err_str = errno ? strerror(errno) :
"Vertex coordinate read failed";
198 float (*vertexCos)[3],
202 const char **err_str)
217 if (index_range[0] == index_range[1]) {
239 float (*vertexCos)[3],
244 const char time_mode,
245 const char **err_str)
253 *err_str = errno ? strerror(errno) :
"Unknown error opening file";
typedef float(TangentPoint)[2]
void BLI_endian_switch_int32_array(int *val, const int size) ATTR_NONNULL(1)
BLI_INLINE void BLI_endian_switch_float(float *val) ATTR_NONNULL(1)
File and directory operations.
int BLI_fseek(FILE *stream, int64_t offset, int whence)
FILE * BLI_fopen(const char *filename, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Compatibility-like things for windows.
@ MOD_MESHCACHE_TIME_FRAME
@ MOD_MESHCACHE_TIME_FACTOR
@ MOD_MESHCACHE_TIME_SECONDS
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 **err_str)
static bool meshcache_read_pc2_head(FILE *fp, const int verts_tot, PC2Head *pc2_head, const char **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 **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 **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 **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 **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 float2 interp(const float2 &a, const float2 &b, float t)