Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_fileops.h1
-rw-r--r--source/blender/blenlib/BLI_fileops_types.h18
-rw-r--r--source/blender/blenlib/BLI_math_geom.h2
-rw-r--r--source/blender/blenlib/BLI_path_util.h2
-rw-r--r--source/blender/blenlib/intern/BLI_filelist.c41
-rw-r--r--source/blender/blenlib/intern/math_geom.c65
-rw-r--r--source/blender/blenlib/intern/path_util.c43
7 files changed, 145 insertions, 27 deletions
diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h
index 01aa5d39b96..642896ac701 100644
--- a/source/blender/blenlib/BLI_fileops.h
+++ b/source/blender/blenlib/BLI_fileops.h
@@ -106,6 +106,7 @@ int BLI_access(const char *filename, int mode) ATTR_WARN_UNUSED_RESULT ATTR_N
bool BLI_file_is_writable(const char *file) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
bool BLI_file_touch(const char *file) ATTR_NONNULL();
+void BLI_file_size_string(off_t st_size, char *size, size_t len);
#if 0 /* UNUSED */
int BLI_file_gzip(const char *from, const char *to) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
diff --git a/source/blender/blenlib/BLI_fileops_types.h b/source/blender/blenlib/BLI_fileops_types.h
index 0e6eab687ad..e596fa55877 100644
--- a/source/blender/blenlib/BLI_fileops_types.h
+++ b/source/blender/blenlib/BLI_fileops_types.h
@@ -34,6 +34,7 @@
*/
#include <sys/stat.h>
+#include "BLI_listbase.h"
#if defined(WIN32) && !defined(FREE_WINDOWS)
typedef unsigned int mode_t;
@@ -41,6 +42,19 @@ typedef unsigned int mode_t;
struct ImBuf;
+typedef struct CollapsedEntry {
+ /* list that gets populated during file open */
+ ListBase list;
+ /* sorted array of the files for quick access of frames */
+ struct direntry **darray;
+ off_t totalsize;
+ int minframe;
+ int maxframe;
+ int numdigits;
+ int totfiles;
+ int curfra;
+} CollapsedEntry;
+
struct direntry {
mode_t type;
char *relname;
@@ -69,6 +83,10 @@ struct direntry {
int nr;
struct ImBuf *image;
unsigned int selflag; /* selection flag */
+ off_t realsize; /* real size of file */
+ int frame; /* frame of file in a movie sequence */
+
+ CollapsedEntry collapsed_info;
};
struct dirlink {
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 2c91aca27ef..a3687ae41f7 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -233,6 +233,8 @@ void fill_poly_v2i_n(
/* tri or quad, d can be NULL */
void interp_weights_face_v3(float w[4],
const float a[3], const float b[3], const float c[3], const float d[3], const float p[3]);
+/* also returns three indices of the triangle actually used */
+void interp_weights_face_v3_index(int tri[3], float w[4], const float v1[3], const float v2[3], const float v3[3], const float v4[3], const float co[3]);
void interp_weights_poly_v3(float w[], float v[][3], const int n, const float co[3]);
void interp_weights_poly_v2(float w[], float v[][2], const int n, const float co[2]);
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h
index 63b5207f941..40aef5eaf2f 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -133,7 +133,7 @@ bool BLI_path_abs(char *path, const char *basepath) ATTR_NONNULL();
bool BLI_path_frame(char *path, int frame, int digits) ATTR_NONNULL();
bool BLI_path_frame_range(char *path, int sta, int end, int digits) ATTR_NONNULL();
bool BLI_path_frame_get(char *path, int *r_frame, int *numdigits) ATTR_NONNULL();
-void BLI_path_frame_strip(char *path, bool setsharp, char *ext) ATTR_NONNULL();
+bool BLI_path_frame_strip(char *path, bool setsharp, char *ext);
bool BLI_path_frame_check_chars(const char *path) ATTR_NONNULL();
bool BLI_path_cwd(char *path) ATTR_NONNULL();
void BLI_path_rel(char *file, const char *relfile) ATTR_NONNULL();
diff --git a/source/blender/blenlib/intern/BLI_filelist.c b/source/blender/blenlib/intern/BLI_filelist.c
index 786eaa74df8..0f2d8e34ca5 100644
--- a/source/blender/blenlib/intern/BLI_filelist.c
+++ b/source/blender/blenlib/intern/BLI_filelist.c
@@ -289,22 +289,28 @@ static void bli_adddirstrings(struct BuildDirCtx *dir_ctx)
* everyone starts using __USE_FILE_OFFSET64 or equivalent.
*/
size = (double)file->s.st_size;
+ file->realsize = size;
- if (size > 1024.0 * 1024.0 * 1024.0 * 1024.0) {
- BLI_snprintf(file->size, sizeof(file->size), "%.1f TiB", size / (1024.0 * 1024.0 * 1024.0 * 1024.0));
- }
- else if (size > 1024.0 * 1024.0 * 1024.0) {
- BLI_snprintf(file->size, sizeof(file->size), "%.1f GiB", size / (1024.0 * 1024.0 * 1024.0));
- }
- else if (size > 1024.0 * 1024.0) {
- BLI_snprintf(file->size, sizeof(file->size), "%.1f MiB", size / (1024.0 * 1024.0));
- }
- else if (size > 1024.0) {
- BLI_snprintf(file->size, sizeof(file->size), "%.1f KiB", size / 1024.0);
- }
- else {
- BLI_snprintf(file->size, sizeof(file->size), "%d B", (int)size);
- }
+ BLI_file_size_string(size, file->size, sizeof(file->size));
+ }
+}
+
+void BLI_file_size_string(off_t st_size, char *size, size_t len)
+{
+ if (st_size > 1024.0 * 1024.0 * 1024.0 * 1024.0) {
+ BLI_snprintf(size, len, "%.1f TiB", st_size / (1024.0 * 1024.0 * 1024.0 * 1024.0));
+ }
+ else if (st_size > 1024.0 * 1024.0 * 1024.0) {
+ BLI_snprintf(size, len, "%.1f GiB", st_size / (1024.0 * 1024.0 * 1024.0));
+ }
+ else if (st_size > 1024.0 * 1024.0) {
+ BLI_snprintf(size, len, "%.1f MiB", st_size / (1024.0 * 1024.0));
+ }
+ else if (st_size > 1024.0) {
+ BLI_snprintf(size, len, "%.1f KiB", st_size / 1024.0);
+ }
+ else {
+ BLI_snprintf(size, len, "%d B", (int)st_size);
}
}
@@ -364,6 +370,9 @@ void BLI_filelist_duplicate(
if (dest->poin && dup_poin) {
dest->poin = dup_poin(src->poin);
}
+ if (dest->collapsed_info.darray) {
+ dest->collapsed_info.darray = NULL;
+ }
}
}
@@ -384,6 +393,8 @@ void BLI_filelist_free(struct direntry *filelist, unsigned int nrentries, void (
MEM_freeN(entry->path);
if (entry->poin && free_poin)
free_poin(entry->poin);
+ if (entry->collapsed_info.darray)
+ MEM_freeN(entry->collapsed_info.darray);
}
if (filelist != NULL) {
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 7329a1177a8..aebe030cd31 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -2487,6 +2487,71 @@ void interp_weights_face_v3(float w[4], const float v1[3], const float v2[3], co
}
}
+void interp_weights_face_v3_index(int tri[3], float w[4], const float v1[3], const float v2[3], const float v3[3], const float v4[3], const float co[3])
+{
+ float w2[3];
+
+ w[0] = w[1] = w[2] = w[3] = 0.0f;
+ tri[0] = tri[1] = tri[2] = -1;
+
+ /* first check for exact match */
+ if (equals_v3v3(co, v1)) {
+ w[0] = 1.0f;
+ tri[0] = 0; tri[1] = 1; tri[2] = 3;
+ }
+ else if (equals_v3v3(co, v2)) {
+ w[1] = 1.0f;
+ tri[0] = 0; tri[1] = 1; tri[2] = 3;
+ }
+ else if (equals_v3v3(co, v3)) {
+ w[2] = 1.0f;
+ tri[0] = 1; tri[1] = 2; tri[2] = 3;
+ }
+ else if (v4 && equals_v3v3(co, v4)) {
+ w[3] = 1.0f;
+ tri[0] = 1; tri[1] = 2; tri[2] = 3;
+ }
+ else {
+ /* otherwise compute barycentric interpolation weights */
+ float n1[3], n2[3], n[3];
+ bool degenerate;
+
+ sub_v3_v3v3(n1, v1, v3);
+ if (v4) {
+ sub_v3_v3v3(n2, v2, v4);
+ }
+ else {
+ sub_v3_v3v3(n2, v2, v3);
+ }
+ cross_v3_v3v3(n, n1, n2);
+
+ /* OpenGL seems to split this way, so we do too */
+ if (v4) {
+ degenerate = barycentric_weights(v1, v2, v4, co, n, w);
+ SWAP(float, w[2], w[3]);
+ tri[0] = 0; tri[1] = 1; tri[2] = 3;
+
+ if (degenerate || (w[0] < 0.0f)) {
+ /* if w[1] is negative, co is on the other side of the v1-v3 edge,
+ * so we interpolate using the other triangle */
+ degenerate = barycentric_weights(v2, v3, v4, co, n, w2);
+
+ if (!degenerate) {
+ w[0] = 0.0f;
+ w[1] = w2[0];
+ w[2] = w2[1];
+ w[3] = w2[2];
+ tri[0] = 1; tri[1] = 2; tri[2] = 3;
+ }
+ }
+ }
+ else {
+ barycentric_weights(v1, v2, v3, co, n, w);
+ tri[0] = 0; tri[1] = 1; tri[2] = 2;
+ }
+ }
+}
+
/* return 1 of point is inside triangle, 2 if it's on the edge, 0 if point is outside of triangle */
int barycentric_inside_triangle_v2(const float w[3])
{
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index c1f6cc4b49a..9f16b604432 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -912,7 +912,7 @@ bool BLI_path_frame_get(char *path, int *r_frame, int *r_numdigits)
return false;
}
-void BLI_path_frame_strip(char *path, bool setsharp, char *ext)
+bool BLI_path_frame_strip(char *path, bool setsharp, char *ext)
{
if (path && *path) {
char *file = (char *)BLI_last_slash(path);
@@ -946,20 +946,41 @@ void BLI_path_frame_strip(char *path, bool setsharp, char *ext)
c++;
- if (numdigits) {
- /* replace the number with the suffix and terminate the string */
- while (numdigits--) {
- if (ext) *ext++ = *suffix;
-
- if (setsharp) *c++ = '#';
- else *c++ = *suffix;
+ if(numdigits) {
+ /* logic here is a bit complex. Idea is: if ext has been provided,
+ * fill it with the extension part and do not keep it in filename
+ * if no ext has been provided, just strip the number or fill it with #
+ */
+ if (ext) {
+ while (*suffix) {
+ *ext++ = *suffix++;
+ }
+ *ext = 0;
- suffix++;
+ if (setsharp) {
+ while (numdigits--) {
+ *c++ = '#';
+ }
+ }
+ *c = 0;
}
- *c = 0;
- if (ext) *ext = 0;
+ else {
+ if (setsharp) {
+ while (numdigits--) {
+ *c++ = '#';
+ }
+ }
+ while (*suffix) {
+ *c++ = *suffix++;
+ }
+ *c = 0;
+ }
+
+ return true;
}
}
+
+ return false;
}