40 if (!fread(pc2_head,
sizeof(*pc2_head), 1, fp)) {
41 *err_str =
"Missing header";
46 *err_str =
"Invalid header";
52 (
sizeof(*pc2_head) -
sizeof(pc2_head->
header)) /
sizeof(
int));
56 *err_str =
"Vertex count mismatch";
61 *err_str =
"Invalid frame total";
100 const char **err_str)
114 else if (frame < 0.0f) {
123 float (*vertexCos)[3],
127 const char **err_str)
136 *err_str =
"Failed to seek frame";
140 size_t verts_read_num = 0;
142 if (factor >= 1.0f) {
143 float *vco = *vertexCos;
145 for (i = pc2_head.
verts_tot; i != 0; i--, vco += 3) {
146 verts_read_num += fread(vco,
sizeof(
float[3]), 1, fp);
148 #ifdef __BIG_ENDIAN__
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);
163 #ifdef __BIG_ENDIAN__
169 vco[0] = (vco[0] * ifactor) + (tvec[0] * factor);
170 vco[1] = (vco[1] * ifactor) + (tvec[1] * factor);
171 vco[2] = (vco[2] * ifactor) + (tvec[2] * factor);
175 if (verts_read_num != pc2_head.
verts_tot) {
176 *err_str = errno ? strerror(errno) :
"Vertex coordinate read failed";
184 float (*vertexCos)[3],
188 const char **err_str)
203 if (index_range[0] == index_range[1]) {
225 float (*vertexCos)[3],
230 const char time_mode,
231 const char **err_str)
239 *err_str = errno ? strerror(errno) :
"Unknown error opening file";
typedef float(TangentPoint)[2]
void BLI_endian_switch_int32_array(int *val, int size) ATTR_NONNULL(1)
BLI_INLINE void BLI_endian_switch_float(float *val) ATTR_NONNULL(1)
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
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)