43 const char **r_err_str)
45 if (!fread(pc2_head,
sizeof(*pc2_head), 1, fp)) {
46 *r_err_str =
RPT_(
"Missing header");
51 *r_err_str =
RPT_(
"Invalid header");
57 (
sizeof(*pc2_head) -
sizeof(pc2_head->
header)) /
sizeof(
int));
61 *r_err_str =
RPT_(
"Vertex count mismatch");
66 *r_err_str =
RPT_(
"Invalid frame total");
85 const char **r_err_str)
105 const char **r_err_str)
119 else if (frame < 0.0f) {
128 float (*vertexCos)[3],
132 const char **r_err_str)
141 *r_err_str =
RPT_(
"Failed to seek frame");
145 size_t verts_read_num = 0;
147 if (factor >= 1.0f) {
148 float *vco = *vertexCos;
150 for (i = pc2_head.
verts_tot; i != 0; i--, vco += 3) {
151 verts_read_num += fread(vco,
sizeof(
float[3]), 1, fp);
161 const float ifactor = 1.0f - factor;
162 float *vco = *vertexCos;
164 for (i = pc2_head.
verts_tot; i != 0; i--, vco += 3) {
166 verts_read_num += fread(tvec,
sizeof(
float[3]), 1, fp);
174 vco[0] = (vco[0] * ifactor) + (tvec[0] * factor);
175 vco[1] = (vco[1] * ifactor) + (tvec[1] * factor);
176 vco[2] = (vco[2] * ifactor) + (tvec[2] * factor);
180 if (verts_read_num != pc2_head.
verts_tot) {
181 *r_err_str = errno ? strerror(errno) :
RPT_(
"Vertex coordinate read failed");
189 float (*vertexCos)[3],
193 const char **r_err_str)
209 if (index_range[0] == index_range[1]) {
233 float (*vertexCos)[3],
238 const char time_mode,
239 const char **r_err_str)
247 *r_err_str = errno ? strerror(errno) :
RPT_(
"Unknown error opening file");
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
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)
draw_view in_light_buf[] float
ccl_device_inline float2 interp(const float2 a, const float2 b, float t)