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_args.h15
-rw-r--r--source/blender/blenlib/BLI_blenlib.h22
-rw-r--r--source/blender/blenlib/BLI_boxpack2d.h13
-rw-r--r--source/blender/blenlib/BLI_bpath.h11
-rw-r--r--source/blender/blenlib/BLI_cpu.h5
-rw-r--r--source/blender/blenlib/BLI_dlrbTree.h7
-rw-r--r--source/blender/blenlib/BLI_dynlib.h (renamed from source/blender/blenlib/PIL_dynlib.h)31
-rw-r--r--source/blender/blenlib/BLI_dynstr.h22
-rw-r--r--source/blender/blenlib/BLI_edgehash.h10
-rw-r--r--source/blender/blenlib/BLI_editVert.h16
-rw-r--r--source/blender/blenlib/BLI_fileops.h12
-rw-r--r--source/blender/blenlib/BLI_fnmatch.h5
-rw-r--r--source/blender/blenlib/BLI_ghash.h11
-rw-r--r--source/blender/blenlib/BLI_graph.h4
-rw-r--r--source/blender/blenlib/BLI_gsqueue.h9
-rw-r--r--source/blender/blenlib/BLI_heap.h9
-rw-r--r--source/blender/blenlib/BLI_jitter.h12
-rw-r--r--source/blender/blenlib/BLI_kdopbvh.h9
-rw-r--r--source/blender/blenlib/BLI_kdtree.h11
-rw-r--r--source/blender/blenlib/BLI_linklist.h10
-rw-r--r--source/blender/blenlib/BLI_listbase.h15
-rw-r--r--source/blender/blenlib/BLI_math.h43
-rw-r--r--source/blender/blenlib/BLI_math_base.h17
-rw-r--r--source/blender/blenlib/BLI_math_color.h6
-rw-r--r--source/blender/blenlib/BLI_math_geom.h135
-rw-r--r--source/blender/blenlib/BLI_math_inline.h6
-rw-r--r--source/blender/blenlib/BLI_math_matrix.h6
-rw-r--r--source/blender/blenlib/BLI_math_rotation.h15
-rw-r--r--source/blender/blenlib/BLI_math_vector.h6
-rw-r--r--source/blender/blenlib/BLI_memarena.h10
-rw-r--r--source/blender/blenlib/BLI_mempool.h24
-rw-r--r--source/blender/blenlib/BLI_noise.h5
-rw-r--r--source/blender/blenlib/BLI_path_util.h43
-rw-r--r--source/blender/blenlib/BLI_pbvh.h11
-rw-r--r--source/blender/blenlib/BLI_rand.h18
-rw-r--r--source/blender/blenlib/BLI_rect.h4
-rw-r--r--source/blender/blenlib/BLI_scanfill.h15
-rw-r--r--source/blender/blenlib/BLI_storage.h6
-rw-r--r--source/blender/blenlib/BLI_storage_types.h14
-rw-r--r--source/blender/blenlib/BLI_string.h16
-rw-r--r--source/blender/blenlib/BLI_threads.h4
-rw-r--r--source/blender/blenlib/BLI_utildefines.h17
-rw-r--r--source/blender/blenlib/BLI_uvproject.h6
-rw-r--r--source/blender/blenlib/BLI_vfontdata.h13
-rw-r--r--source/blender/blenlib/BLI_voxel.h9
-rw-r--r--source/blender/blenlib/BLI_winstuff.h13
-rw-r--r--source/blender/blenlib/CMakeLists.txt6
-rw-r--r--source/blender/blenlib/PIL_time.h31
-rw-r--r--source/blender/blenlib/SConscript7
-rw-r--r--source/blender/blenlib/intern/BLI_args.c15
-rw-r--r--source/blender/blenlib/intern/BLI_callbacks.h7
-rw-r--r--source/blender/blenlib/intern/BLI_dynstr.c7
-rw-r--r--source/blender/blenlib/intern/BLI_ghash.c11
-rw-r--r--source/blender/blenlib/intern/BLI_heap.c9
-rw-r--r--source/blender/blenlib/intern/BLI_kdopbvh.c16
-rw-r--r--source/blender/blenlib/intern/BLI_kdtree.c11
-rw-r--r--source/blender/blenlib/intern/BLI_linklist.c7
-rw-r--r--source/blender/blenlib/intern/BLI_memarena.c7
-rw-r--r--source/blender/blenlib/intern/BLI_mempool.c8
-rw-r--r--source/blender/blenlib/intern/DLRB_tree.c7
-rw-r--r--source/blender/blenlib/intern/boxpack2d.c25
-rw-r--r--source/blender/blenlib/intern/bpath.c17
-rw-r--r--source/blender/blenlib/intern/cpu.c7
-rw-r--r--source/blender/blenlib/intern/dynamiclist.h7
-rw-r--r--source/blender/blenlib/intern/dynlib.c108
-rw-r--r--source/blender/blenlib/intern/edgehash.c7
-rw-r--r--source/blender/blenlib/intern/fileops.c28
-rw-r--r--source/blender/blenlib/intern/fnmatch.c3
-rw-r--r--source/blender/blenlib/intern/freetypefont.c69
-rw-r--r--source/blender/blenlib/intern/graph.c11
-rw-r--r--source/blender/blenlib/intern/gsqueue.c7
-rw-r--r--source/blender/blenlib/intern/jitter.c8
-rw-r--r--source/blender/blenlib/intern/listbase.c68
-rw-r--r--source/blender/blenlib/intern/math_base.c7
-rw-r--r--source/blender/blenlib/intern/math_base_inline.c15
-rw-r--r--source/blender/blenlib/intern/math_color.c31
-rw-r--r--source/blender/blenlib/intern/math_geom.c361
-rw-r--r--source/blender/blenlib/intern/math_geom_inline.c21
-rw-r--r--source/blender/blenlib/intern/math_matrix.c37
-rw-r--r--source/blender/blenlib/intern/math_rotation.c85
-rw-r--r--source/blender/blenlib/intern/math_vector.c21
-rw-r--r--source/blender/blenlib/intern/math_vector_inline.c27
-rw-r--r--source/blender/blenlib/intern/noise.c25
-rw-r--r--source/blender/blenlib/intern/path_util.c431
-rw-r--r--source/blender/blenlib/intern/pbvh.c168
-rw-r--r--source/blender/blenlib/intern/rand.c7
-rw-r--r--source/blender/blenlib/intern/rct.c12
-rw-r--r--source/blender/blenlib/intern/scanfill.c10
-rw-r--r--source/blender/blenlib/intern/storage.c40
-rw-r--r--source/blender/blenlib/intern/string.c141
-rw-r--r--source/blender/blenlib/intern/threads.c9
-rw-r--r--source/blender/blenlib/intern/time.c10
-rw-r--r--source/blender/blenlib/intern/uvproject.c26
-rw-r--r--source/blender/blenlib/intern/voxel.c7
-rw-r--r--source/blender/blenlib/intern/winstuff.c138
95 files changed, 1748 insertions, 1116 deletions
diff --git a/source/blender/blenlib/BLI_args.h b/source/blender/blenlib/BLI_args.h
index 2927314e225..4cdb35dd675 100644
--- a/source/blender/blenlib/BLI_args.h
+++ b/source/blender/blenlib/BLI_args.h
@@ -1,6 +1,4 @@
-/**
- * A general argument parsing module
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -32,13 +30,18 @@
#ifndef BLI_ARGS_H
#define BLI_ARGS_H
+/** \file BLI_args.h
+ * \ingroup bli
+ * \brief A general argument parsing module.
+ */
+
struct bArgs;
typedef struct bArgs bArgs;
/* returns the number of extra arguments consumed by the function. 0 is normal value, -1 stops parsing arguments, other negative indicates skip */
-typedef int (*BA_ArgCallback)(int argc, char **argv, void *data);
+typedef int (*BA_ArgCallback)(int argc, const char **argv, void *data);
-struct bArgs *BLI_argsInit(int argc, char **argv);
+struct bArgs *BLI_argsInit(int argc, const char **argv);
void BLI_argsFree(struct bArgs *ba);
/* pass starts at 1, -1 means valid all the time
@@ -54,6 +57,6 @@ void BLI_argsPrintArgDoc(struct bArgs *ba, const char *arg);
void BLI_argsPrintOtherDoc(struct bArgs *ba);
void BLI_argsPrint(struct bArgs *ba);
-char **BLI_argsArgv(struct bArgs *ba);
+const char **BLI_argsArgv(struct bArgs *ba);
#endif
diff --git a/source/blender/blenlib/BLI_blenlib.h b/source/blender/blenlib/BLI_blenlib.h
index 8423c07e7c9..ba5d04f3021 100644
--- a/source/blender/blenlib/BLI_blenlib.h
+++ b/source/blender/blenlib/BLI_blenlib.h
@@ -25,10 +25,14 @@
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file BLI_blenlib.h
+ * \ingroup bli
*
- * @mainpage BLI - Blender LIbrary external interface
+ * \section aboutbli Blender LIbrary external interface
*
- * @section about About the BLI module
+ * \subsection about About the BLI module
*
* This is the external interface of the Blender Library. If you find
* a call to a BLI function that is not prototyped here, please add a
@@ -39,25 +43,19 @@
* allocation/deallocation. There is also a patch to make MS Windows
* behave more or less Posix-compliant.
*
- * @section issues Known issues with BLI
+ * \subsection issues Known issues with BLI
*
* - blenlib is written in C.
* - The posix-compliancy may move to a separate lib that deals with
* platform dependencies. (There are other platform-dependent
* fixes as well.)
* - The file i/o has some redundant code. It should be cleaned.
- * - arithb.c is a very messy matrix library. We need a better
- * solution.
- * - vectorops.c is close to superfluous. It may disappear in the
- * near future.
*
- * @section dependencies Dependencies
+ * \subsection dependencies Dependencies
*
- * - The blenlib uses type defines from makesdna/, and functions from
+ * - The blenlib uses type defines from \ref DNA, and functions from
* standard libraries.
- *
- * $Id$
-*/
+ */
#ifndef BLI_BLENLIB_H
#define BLI_BLENLIB_H
diff --git a/source/blender/blenlib/BLI_boxpack2d.h b/source/blender/blenlib/BLI_boxpack2d.h
index 008af55e1d0..886965f66b3 100644
--- a/source/blender/blenlib/BLI_boxpack2d.h
+++ b/source/blender/blenlib/BLI_boxpack2d.h
@@ -1,6 +1,4 @@
-/**
- *
- *
+/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -27,6 +25,13 @@
* ***** END GPL LICENSE BLOCK *****
*/
+#ifndef _BLI_BOXPACK2D_H_
+#define _BLI_BOXPACK2D_H_
+
+/** \file BLI_boxpack2d.h
+ * \ingroup bli
+ */
+
/* Box Packer */
typedef struct boxPack {
@@ -43,3 +48,5 @@ typedef struct boxPack {
void boxPack2D(boxPack *boxarray, const int len, float *tot_width, float *tot_height);
+#endif
+
diff --git a/source/blender/blenlib/BLI_bpath.h b/source/blender/blenlib/BLI_bpath.h
index 8c351d6020d..cfe5d7f2084 100644
--- a/source/blender/blenlib/BLI_bpath.h
+++ b/source/blender/blenlib/BLI_bpath.h
@@ -1,4 +1,4 @@
-/**
+/*
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
@@ -26,8 +26,11 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/* Based on ghash, difference is ghash is not a fixed size,
- * so for BPath we dont need to malloc */
+/** \file BLI_bpath.h
+ * \ingroup bli
+ * \attention Based on ghash, difference is ghash is not a fixed size,
+ * so for BPath we dont need to malloc
+ */
#ifndef BLI_BPATH_H
#define BLI_BPATH_H
@@ -41,7 +44,7 @@ void BLI_bpathIterator_free (struct BPathIterator *bpi);
const char* BLI_bpathIterator_getLib (struct BPathIterator *bpi);
const char* BLI_bpathIterator_getName (struct BPathIterator *bpi);
int BLI_bpathIterator_getType (struct BPathIterator *bpi);
-int BLI_bpathIterator_getPathMaxLen (struct BPathIterator *bpi);
+unsigned int BLI_bpathIterator_getPathMaxLen (struct BPathIterator *bpi);
const char* BLI_bpathIterator_getBasePath (struct BPathIterator *bpi);
void BLI_bpathIterator_step (struct BPathIterator *bpi);
int BLI_bpathIterator_isDone (struct BPathIterator *bpi);
diff --git a/source/blender/blenlib/BLI_cpu.h b/source/blender/blenlib/BLI_cpu.h
index d809f1cc594..addcf1273b3 100644
--- a/source/blender/blenlib/BLI_cpu.h
+++ b/source/blender/blenlib/BLI_cpu.h
@@ -1,5 +1,4 @@
/*
- *
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -24,6 +23,10 @@
#ifndef BLI_CPU_H
#define BLI_CPU_H
+/** \file BLI_cpu.h
+ * \ingroup bli
+ */
+
int BLI_cpu_support_sse2(void);
#endif
diff --git a/source/blender/blenlib/BLI_dlrbTree.h b/source/blender/blenlib/BLI_dlrbTree.h
index 4b3768c3547..24c819ada55 100644
--- a/source/blender/blenlib/BLI_dlrbTree.h
+++ b/source/blender/blenlib/BLI_dlrbTree.h
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -28,6 +28,11 @@
#ifndef BLI_DLRB_TREE_H
#define BLI_DLRB_TREE_H
+/** \file BLI_dlrbTree.h
+ * \ingroup bli
+ * \author Joshua Leung
+ */
+
/* Double-Linked Red-Black Tree Implementation:
*
* This is simply a Red-Black Tree implementation whose nodes can later
diff --git a/source/blender/blenlib/PIL_dynlib.h b/source/blender/blenlib/BLI_dynlib.h
index c94b6af690b..f269bedd639 100644
--- a/source/blender/blenlib/PIL_dynlib.h
+++ b/source/blender/blenlib/BLI_dynlib.h
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -26,27 +26,20 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
-#ifndef __PIL_DYNLIB_H__
-#define __PIL_DYNLIB_H__
-typedef struct PILdynlib PILdynlib;
+/** \file blender/blenlib/BLI_dynlib.h
+ * \ingroup bli
+ */
- PILdynlib*
-PIL_dynlib_open(
- char *name);
+#ifndef __BLI_DYNLIB_H__
+#define __BLI_DYNLIB_H__
- void*
-PIL_dynlib_find_symbol(
- PILdynlib* lib,
- const char *symname);
+typedef struct DynamicLibrary DynamicLibrary;
- char*
-PIL_dynlib_get_error_as_string(
- PILdynlib* lib);
-
- void
-PIL_dynlib_close(
- PILdynlib* lib);
+DynamicLibrary *BLI_dynlib_open(char *name);
+void *BLI_dynlib_find_symbol(DynamicLibrary* lib, const char *symname);
+char *BLI_dynlib_get_error_as_string(DynamicLibrary* lib);
+void BLI_dynlib_close(DynamicLibrary* lib);
-#endif /* __PIL_DYNLIB_H__ */
+#endif /* __BLI_DYNLIB_H__ */
diff --git a/source/blender/blenlib/BLI_dynstr.h b/source/blender/blenlib/BLI_dynstr.h
index 34e77007d95..2cbc19f56f0 100644
--- a/source/blender/blenlib/BLI_dynstr.h
+++ b/source/blender/blenlib/BLI_dynstr.h
@@ -1,12 +1,4 @@
-/**
- * @file BLI_dynstr.h
- *
- * A dynamically sized string ADT.
- * This ADT is designed purely for dynamic string creation
- * through appending, not for general usage, the intent is
- * to build up dynamic strings using a DynStr object, then
- * convert it to a c-string and work with that.
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -38,6 +30,16 @@
#ifndef BLI_DYNSTR_H
#define BLI_DYNSTR_H
+/** \file BLI_dynstr.h
+ * \ingroup bli
+ * \brief A dynamically sized string ADT.
+ * \section aboutdynstr Dynamic String
+ * This ADT is designed purely for dynamic string creation
+ * through appending, not for general usage, the intent is
+ * to build up dynamic strings using a DynStr object, then
+ * convert it to a c-string and work with that.
+ */
+
#include <stdarg.h>
struct DynStr;
@@ -77,7 +79,7 @@ void BLI_dynstr_nappend (DynStr *ds, const char *cstr, int len);
*/
void BLI_dynstr_appendf (DynStr *ds, const char *format, ...)
#ifdef __GNUC__
-__attribute__ ((format (printf, 2, 3)));
+__attribute__ ((format (printf, 2, 3)))
#endif
;
void BLI_dynstr_vappendf (DynStr *ds, const char *format, va_list args);
diff --git a/source/blender/blenlib/BLI_edgehash.h b/source/blender/blenlib/BLI_edgehash.h
index e74910ddb09..fba13035f02 100644
--- a/source/blender/blenlib/BLI_edgehash.h
+++ b/source/blender/blenlib/BLI_edgehash.h
@@ -1,6 +1,4 @@
-/**
- * A general unordered 2-int pair hash table ADT
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -32,6 +30,12 @@
#ifndef BLI_EDGEHASH_H
#define BLI_EDGEHASH_H
+/** \file BLI_storage.h
+ * \ingroup bli
+ * \author Daniel Dunbar
+ * \brief A general unordered 2-int pair hash table ADT.
+ */
+
struct EdgeHash;
struct EdgeHashIterator;
typedef struct EdgeHash EdgeHash;
diff --git a/source/blender/blenlib/BLI_editVert.h b/source/blender/blenlib/BLI_editVert.h
index 051778772e0..ba745af5a0b 100644
--- a/source/blender/blenlib/BLI_editVert.h
+++ b/source/blender/blenlib/BLI_editVert.h
@@ -1,9 +1,4 @@
-/**
- * blenlib/BLI_editVert.h mar 2001 Nzc
- *
- * Some editing types needed in the lib (unfortunately) for
- * scanfill.c
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -35,6 +30,14 @@
#ifndef BLI_EDITVERT_H
#define BLI_EDITVERT_H
+/** \file BLI_editVert.h
+ * \ingroup bli
+ * \since March 2001
+ * \author nzc
+ * \brief Some editing types needed in the lib (unfortunately) for
+ * scanfill.c
+ */
+
#include "DNA_customdata_types.h"
#include "DNA_mesh_types.h"
@@ -57,6 +60,7 @@ typedef struct EditVert
void *p;
intptr_t l;
float fp;
+ int t;
} tmp;
float no[3]; /*vertex normal */
float co[3]; /*vertex location */
diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h
index 95d890f133f..59c01348c07 100644
--- a/source/blender/blenlib/BLI_fileops.h
+++ b/source/blender/blenlib/BLI_fileops.h
@@ -1,6 +1,4 @@
-/**
- * blenlib/BLI_listBase.h mar 2001 Nzc
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -27,8 +25,12 @@
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
- *
- * More low-level fileops from Daniel Dunbar. Two functions were also
+ */
+
+/** \file BLI_fileops.h
+ * \ingroup bli
+ * \author Daniel Dunbar
+ * \brief More low-level fileops from Daniel Dunbar. Two functions were also
* defined in storage.c. These are the old fop_ prefixes. There is
* definitely some redundancy here!
* */
diff --git a/source/blender/blenlib/BLI_fnmatch.h b/source/blender/blenlib/BLI_fnmatch.h
index 1dffb285451..94ae741250f 100644
--- a/source/blender/blenlib/BLI_fnmatch.h
+++ b/source/blender/blenlib/BLI_fnmatch.h
@@ -18,9 +18,12 @@ along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef _FNMATCH_H
-
#define _FNMATCH_H 1
+/** \file BLI_fnmatch.h
+ * \ingroup bli
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h
index 46c0f767b5f..dcc71fa1258 100644
--- a/source/blender/blenlib/BLI_ghash.h
+++ b/source/blender/blenlib/BLI_ghash.h
@@ -1,6 +1,4 @@
-/**
- * A general (pointer -> pointer) hash table ADT
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -32,6 +30,11 @@
#ifndef BLI_GHASH_H
#define BLI_GHASH_H
+/** \file BLI_ghash.h
+ * \ingroup bli
+ * \brief A general (pointer -> pointer) hash table ADT
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -228,7 +231,7 @@ BM_INLINE int BLI_ghash_remove (GHash *gh, void *key, GHashKeyFreeFP keyfreefp,
{
unsigned int hash= gh->hashfp(key)%gh->nbuckets;
Entry *e;
- Entry *p = 0;
+ Entry *p = NULL;
for (e= gh->buckets[hash]; e; e= e->next) {
if (gh->cmpfp(key, e->key)==0) {
diff --git a/source/blender/blenlib/BLI_graph.h b/source/blender/blenlib/BLI_graph.h
index 1dd439468f7..f625c7bb2d4 100644
--- a/source/blender/blenlib/BLI_graph.h
+++ b/source/blender/blenlib/BLI_graph.h
@@ -1,6 +1,10 @@
#ifndef BLI_GRAPH_H_
#define BLI_GRAPH_H_
+/** \file BLI_graph.h
+ * \ingroup bli
+ */
+
#include "DNA_listBase.h"
struct BGraph;
diff --git a/source/blender/blenlib/BLI_gsqueue.h b/source/blender/blenlib/BLI_gsqueue.h
index afc4cb38b10..572c54b7b7e 100644
--- a/source/blender/blenlib/BLI_gsqueue.h
+++ b/source/blender/blenlib/BLI_gsqueue.h
@@ -1,7 +1,4 @@
/*
- * A generic structure queue (a queue for fixed length
- * (generally small) structures.
- *
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -33,6 +30,12 @@
#ifndef BLI_GSQUEUE_H
#define BLI_GSQUEUE_H
+/** \file BLI_gsqueue.h
+ * \ingroup bli
+ * \brief A generic structure queue (a queue for fixed length
+ * (generally small) structures.
+ */
+
typedef struct _GSQueue GSQueue;
/**
diff --git a/source/blender/blenlib/BLI_heap.h b/source/blender/blenlib/BLI_heap.h
index a6663726f8b..3038d026df9 100644
--- a/source/blender/blenlib/BLI_heap.h
+++ b/source/blender/blenlib/BLI_heap.h
@@ -1,6 +1,4 @@
-/**
- * A heap / priority queue ADT
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -32,6 +30,11 @@
#ifndef BLI_HEAP_H
#define BLI_HEAP_H
+/** \file BLI_heap.h
+ * \ingroup bli
+ * \brief A heap / priority queue ADT
+ */
+
struct Heap;
struct HeapNode;
typedef struct Heap Heap;
diff --git a/source/blender/blenlib/BLI_jitter.h b/source/blender/blenlib/BLI_jitter.h
index f626feb2ec8..e0fea9306ff 100644
--- a/source/blender/blenlib/BLI_jitter.h
+++ b/source/blender/blenlib/BLI_jitter.h
@@ -1,6 +1,4 @@
/*
- * jitter.h
- *
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -32,9 +30,13 @@
#ifndef BLI_JITTER_H
#define BLI_JITTER_H
-extern void BLI_initjit(float *jitarr, int num);
-extern void BLI_jitterate1(float *jit1, float *jit2, int num, float rad1);
-extern void BLI_jitterate2(float *jit1, float *jit2, int num, float rad2);
+/** \file BLI_jitter.h
+ * \ingroup bli
+ */
+
+void BLI_initjit(float *jitarr, int num);
+void BLI_jitterate1(float *jit1, float *jit2, int num, float rad1);
+void BLI_jitterate2(float *jit1, float *jit2, int num, float rad2);
#endif
diff --git a/source/blender/blenlib/BLI_kdopbvh.h b/source/blender/blenlib/BLI_kdopbvh.h
index aa55ececc06..d0943408dc5 100644
--- a/source/blender/blenlib/BLI_kdopbvh.h
+++ b/source/blender/blenlib/BLI_kdopbvh.h
@@ -1,5 +1,4 @@
-/**
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -32,6 +31,12 @@
#ifndef BLI_KDOPBVH_H
#define BLI_KDOPBVH_H
+/** \file BLI_kdopbvh.h
+ * \ingroup bli
+ * \author Daniel Genrich
+ * \author Andre Pinto
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/source/blender/blenlib/BLI_kdtree.h b/source/blender/blenlib/BLI_kdtree.h
index 95f9e6939d0..c607dae386f 100644
--- a/source/blender/blenlib/BLI_kdtree.h
+++ b/source/blender/blenlib/BLI_kdtree.h
@@ -1,6 +1,4 @@
-/**
- * A kd-tree for nearest neighbour search.
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -33,6 +31,13 @@
#ifndef BLI_KDTREE_H
#define BLI_KDTREE_H
+/** \file BLI_kdtree.h
+ * \ingroup bli
+ * \brief A kd-tree for nearest neighbour search.
+ * \author Janne Karhu
+ * \author Brecht van Lommel
+ */
+
struct KDTree;
typedef struct KDTree KDTree;
diff --git a/source/blender/blenlib/BLI_linklist.h b/source/blender/blenlib/BLI_linklist.h
index b10d48e3ee6..95850c44ea1 100644
--- a/source/blender/blenlib/BLI_linklist.h
+++ b/source/blender/blenlib/BLI_linklist.h
@@ -1,7 +1,4 @@
/*
- * Routines for working with singly linked lists
- * of 'links' - pointers to other data.
- *
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -33,6 +30,13 @@
#ifndef BLI_LINKLIST_H
#define BLI_LINKLIST_H
+/** \file BLI_linklist.h
+ * \ingroup bli
+ * \brief Routines for working with singly linked lists
+ * of 'links' - pointers to other data.
+ *
+ */
+
struct MemArena;
typedef void (*LinkNodeFreeFP)(void *link);
diff --git a/source/blender/blenlib/BLI_listbase.h b/source/blender/blenlib/BLI_listbase.h
index a41b49de242..90556ea4b05 100644
--- a/source/blender/blenlib/BLI_listbase.h
+++ b/source/blender/blenlib/BLI_listbase.h
@@ -25,13 +25,15 @@
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
- *
- * $Id$
*/
#ifndef BLI_LISTBASE_H
#define BLI_LISTBASE_H
+/** \file BLI_listbase.h
+ * \ingroup bli
+ */
+
#include "DNA_listBase.h"
//struct ListBase;
//struct LinkData;
@@ -43,9 +45,16 @@ extern "C" {
void BLI_insertlink(struct ListBase *listbase, void *vprevlink, void *vnewlink);
void *BLI_findlink(const struct ListBase *listbase, int number);
int BLI_findindex(const struct ListBase *listbase, void *vlink);
+int BLI_findstringindex(const struct ListBase *listbase, const char *id, const int offset);
+
+/* find forwards */
void *BLI_findstring(const struct ListBase *listbase, const char *id, const int offset);
void *BLI_findstring_ptr(const struct ListBase *listbase, const char *id, const int offset);
-int BLI_findstringindex(const struct ListBase *listbase, const char *id, const int offset);
+
+/* find backwards */
+void *BLI_rfindstring(const struct ListBase *listbase, const char *id, const int offset);
+void *BLI_rfindstring_ptr(const struct ListBase *listbase, const char *id, const int offset);
+
void BLI_freelistN(struct ListBase *listbase);
void BLI_addtail(struct ListBase *listbase, void *vlink);
void BLI_remlink(struct ListBase *listbase, void *vlink);
diff --git a/source/blender/blenlib/BLI_math.h b/source/blender/blenlib/BLI_math.h
index 29a17f362d4..890a5ee4018 100644
--- a/source/blender/blenlib/BLI_math.h
+++ b/source/blender/blenlib/BLI_math.h
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -28,29 +28,30 @@
#ifndef BLI_MATH_H
#define BLI_MATH_H
-/* Abbreviations:
+/** \file BLI_math.h
+ * \ingroup bli
+ * \section mathabbrev Abbreviations
*
- * fl = float
- * db = double
- * v2 = vec2 = vector 2
- * v3 = vec3 = vector 3
- * v4 = vec4 = vector 4
- * qt = quat = quaternion
- * dq = dquat = dual quaternion
- * m2 = mat2 = matrix 2x2
- * m3 = mat3 = matrix 3x3
- * m4 = mat4 = matrix 4x4
- * eul = euler rotation
- * eulO = euler with order
+ * - fl = float
+ * - db = double
+ * - v2 = vec2 = vector 2
+ * - v3 = vec3 = vector 3
+ * - v4 = vec4 = vector 4
+ * - qt = quat = quaternion
+ * - dq = dquat = dual quaternion
+ * - m2 = mat2 = matrix 2x2
+ * - m3 = mat3 = matrix 3x3
+ * - m4 = mat4 = matrix 4x4
+ * - eul = euler rotation
+ * - eulO = euler with order
*
- * Variable Names:
- *
- * f = single value
- * a, b, c = vectors
- * r = result vector
- * A, B, C = matrices
- * R = result matrix
+ * \section mathvarnames Variable Names
*
+ * - f = single value
+ * - a, b, c = vectors
+ * - r = result vector
+ * - A, B, C = matrices
+ * - R = result matrix
*/
#include "BLI_math_base.h"
diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h
index 9ab9621be01..6ff57b08724 100644
--- a/source/blender/blenlib/BLI_math_base.h
+++ b/source/blender/blenlib/BLI_math_base.h
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -28,9 +28,9 @@
#ifndef BLI_MATH_BASE_H
#define BLI_MATH_BASE_H
-#ifdef __cplusplus
-extern "C" {
-#endif
+/** \file BLI_math_base.h
+ * \ingroup bli
+ */
#ifdef WIN32
#define _USE_MATH_DEFINES
@@ -167,11 +167,12 @@ MINLINE float power_of_2(float f);
MINLINE float shell_angle_to_dist(float angle);
-double double_round(double x, int ndigits);
-
-#ifdef __cplusplus
-}
+#if (defined(WIN32) || defined(WIN64)) && !defined(FREE_WINDOWS)
+extern double copysign(double x, double y);
+extern double round(double x);
#endif
+double double_round(double x, int ndigits);
+
#endif /* BLI_MATH_BASE_H */
diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h
index bf466c0f809..fe09706cb3d 100644
--- a/source/blender/blenlib/BLI_math_color.h
+++ b/source/blender/blenlib/BLI_math_color.h
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -28,6 +28,10 @@
#ifndef BLI_MATH_COLOR_H
#define BLI_MATH_COLOR_H
+/** \file BLI_math_color.h
+ * \ingroup bli
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 8f939e5dc61..756d1501536 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -28,6 +28,10 @@
#ifndef BLI_MATH_GEOM_H
#define BLI_MATH_GEOM_H
+/** \file BLI_math_geom.h
+ * \ingroup bli
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -40,8 +44,8 @@ extern "C" {
/********************************** Polygons *********************************/
-void cent_tri_v3(float r[3], float a[3], float b[3], float c[3]);
-void cent_quad_v3(float r[3], float a[3], float b[3], float c[3], float d[3]);
+void cent_tri_v3(float r[3], const float a[3], const float b[3], const float c[3]);
+void cent_quad_v3(float r[3], const float a[3], const float b[3], const float c[3], const float d[3]);
float normal_tri_v3(float r[3], const float a[3], const float b[3], const float c[3]);
float normal_quad_v3(float r[3], const float a[3], const float b[3], const float c[3], const float d[3]);
@@ -50,17 +54,17 @@ float area_tri_v2(const float a[2], const float b[2], const float c[2]);
float area_tri_signed_v2(const float v1[2], const float v2[2], const float v3[2]);
float area_tri_v3(const float a[3], const float b[3], const float c[3]);
float area_quad_v3(const float a[3], const float b[3], const float c[3], const float d[3]);
-float area_poly_v3(int nr, float verts[][3], float normal[3]);
+float area_poly_v3(int nr, float verts[][3], const float normal[3]);
/********************************* Distance **********************************/
-float dist_to_line_v2(float p[2], float l1[2], float l2[2]);
-float dist_to_line_segment_v2(float p[2], float l1[2], float l2[2]);
+float dist_to_line_v2(const float p[2], const float l1[2], const float l2[2]);
+float dist_to_line_segment_v2(const float p[2], const float l1[2], const float l2[2]);
-float dist_to_line_segment_v3(float p[3], float l1[3], float l2[3]);
+float dist_to_line_segment_v3(const float p[3], const float l1[3], const float l2[3]);
float closest_to_line_v3(float r[3], const float p[3], const float l1[3], const float l2[3]);
float closest_to_line_v2(float r[2], const float p[2], const float l1[2], const float l2[2]);
-void closest_to_line_segment_v3(float r[3], float p[3], float l1[3], float l2[3]);
+void closest_to_line_segment_v3(float r[3], const float p[3], const float l1[3], const float l2[3]);
/******************************* Intersection ********************************/
@@ -74,7 +78,7 @@ void closest_to_line_segment_v3(float r[3], float p[3], float l1[3], float l2[3]
int isect_line_line_v2(const float a1[2], const float a2[2], const float b1[2], const float b2[2]);
int isect_line_line_v2_short(const short a1[2], const short a2[2], const short b1[2], const short b2[2]);
-int isect_seg_seg_v2_point(const float *v1, const float *v2, const float *v3, const float *v4, float vi[2]);
+int isect_seg_seg_v2_point(const float v1[2], const float v2[2], const float v3[2], const float v4[2], float vi[2]);
/* Returns the number of point of interests
* 0 - lines are colinear
@@ -82,57 +86,62 @@ int isect_seg_seg_v2_point(const float *v1, const float *v2, const float *v3, co
* 2 - i1 and i2 are the nearest points on line 1 (v1, v2) and line 2 (v3, v4) respectively
* */
-int isect_line_line_v3(float v1[3], float v2[3],
- float v3[3], float v4[3], float i1[3], float i2[3]);
-int isect_line_line_strict_v3(float v1[3], float v2[3],
- float v3[3], float v4[3], float vi[3], float *lambda);
+int isect_line_line_v3(const float v1[3], const float v2[3],
+ const float v3[3], const float v4[3], float i1[3], float i2[3]);
+int isect_line_line_strict_v3(const float v1[3], const float v2[3],
+ const float v3[3], const float v4[3], float vi[3], float *lambda);
+
+/*if clip is nonzero, will only return true if lambda is >= 0.0
+ (i.e. intersection point is along positive d)*/
+int isect_ray_plane_v3(float p1[3], float d[3], float v0[3],
+ float v1[3], float v2[3], float *lambda, int clip);
/* line/ray triangle */
-int isect_line_tri_v3(float p1[3], float p2[3],
- float v0[3], float v1[3], float v2[3], float *lambda, float *uv);
-int isect_ray_tri_v3(float p1[3], float d[3],
- float v0[3], float v1[3], float v2[3], float *lambda, float *uv);
-int isect_ray_tri_threshold_v3(float p1[3], float d[3],
- float v0[3], float v1[3], float v2[3], float *lambda, float *uv, float threshold);
-int isect_ray_tri_epsilon_v3(float p1[3], float d[3],
- float v0[3], float v1[3], float v2[3], float *lambda, float *uv, float epsilon);
+int isect_line_tri_v3(const float p1[3], const float p2[3],
+ const float v0[3], const float v1[3], const float v2[3], float *lambda, float uv[2]);
+int isect_ray_tri_v3(const float p1[3], const float d[3],
+ const float v0[3], const float v1[3], const float v2[3], float *lambda, float uv[2]);
+int isect_ray_tri_threshold_v3(const float p1[3], const float d[3],
+ const float v0[3], const float v1[3], const float v2[3], float *lambda, float uv[2], const float threshold);
+int isect_ray_tri_epsilon_v3(const float p1[3], const float d[3],
+ const float v0[3], const float v1[3], const float v2[3], float *lambda, float uv[2], const float epsilon);
/* point in polygon */
-int isect_point_quad_v2(float p[2], float a[2], float b[2], float c[2], float d[2]);
+int isect_point_quad_v2(const float p[2], const float a[2], const float b[2], const float c[2], const float d[2]);
-int isect_point_tri_v2(float v1[2], float v2[2], float v3[2], float pt[2]);
-int isect_point_tri_v2_int(int x1, int y1, int x2, int y2, int a, int b);
-int isect_point_tri_prism_v3(float p[3], float v1[3], float v2[3], float v3[3]);
+int isect_point_tri_v2(const float v1[2], const float v2[2], const float v3[2], const float pt[2]);
+int isect_point_tri_v2_int(const int x1, const int y1, const int x2, const int y2, const int a, const int b);
+int isect_point_tri_prism_v3(const float p[3], const float v1[3], const float v2[3], const float v3[3]);
-void isect_point_quad_uv_v2(float v0[2], float v1[2], float v2[2], float v3[2],
- float pt[2], float *uv);
-void isect_point_face_uv_v2(int isquad, float v0[2], float v1[2], float v2[2],
- float v3[2], float pt[2], float *uv);
+void isect_point_quad_uv_v2(const float v0[2], const float v1[2], const float v2[2], const float v3[2],
+ const float pt[2], float *uv);
+void isect_point_face_uv_v2(const int isquad, const float v0[2], const float v1[2], const float v2[2],
+ const float v3[2], const float pt[2], float *uv);
/* other */
-int isect_sweeping_sphere_tri_v3(float p1[3], float p2[3], float radius,
- float v0[3], float v1[3], float v2[3], float *lambda, float *ipoint);
+int isect_sweeping_sphere_tri_v3(const float p1[3], const float p2[3], const float radius,
+ const float v0[3], const float v1[3], const float v2[3], float *lambda, float ipoint[3]);
-int isect_axial_line_tri_v3(int axis, float co1[3], float co2[3],
- float v0[3], float v1[3], float v2[3], float *lambda);
+int isect_axial_line_tri_v3(const int axis, const float co1[3], const float co2[3],
+ const float v0[3], const float v1[3], const float v2[3], float *lambda);
-int isect_aabb_aabb_v3(float min1[3], float max1[3], float min2[3], float max2[3]);
+int isect_aabb_aabb_v3(const float min1[3], const float max1[3], const float min2[3], const float max2[3]);
-int clip_line_plane(float clipco[3], float plane[4], float co[3]);
+int clip_line_plane(float p1[3], float p2[3], const float plane[4]);
-void plot_line_v2v2i(int p1[2], int p2[2], int (*callback)(int, int, void *), void *userData);
+void plot_line_v2v2i(const int p1[2], const int p2[2], int (*callback)(int, int, void *), void *userData);
/****************************** Interpolation ********************************/
/* tri or quad, d can be NULL */
void interp_weights_face_v3(float w[4],
- float a[3], float b[3], float c[3], float d[3], float p[3]);
-void interp_weights_poly_v3(float w[], float v[][3], int n, float p[3]);
+ const float a[3], const float b[3], const float c[3], const float d[3], const float p[3]);
+void interp_weights_poly_v3(float w[], float v[][3], const int n, const float p[3]);
void interp_cubic_v3(float x[3], float v[3],
- float x1[3], float v1[3], float x2[3], float v2[3], float t);
+ const float x1[3], const float v1[3], const float x2[3], const float v2[3], const float t);
-int interp_sparse_array(float *array, int list_size, float invalid);
+int interp_sparse_array(float *array, const int list_size, const float invalid);
void barycentric_transform(float pt_tar[3], float const pt_src[3],
const float tri_tar_p1[3], const float tri_tar_p2[3], const float tri_tar_p3[3],
@@ -148,22 +157,28 @@ void lookat_m4(float mat[4][4], float vx, float vy,
void polarview_m4(float mat[4][4], float dist, float azimuth,
float incidence, float twist);
-void perspective_m4(float mat[4][4], float left, float right,
- float bottom, float top, float nearClip, float farClip);
-void orthographic_m4(float mat[4][4], float left, float right,
- float bottom, float top, float nearClip, float farClip);
+void perspective_m4(float mat[4][4], const float left, const float right,
+ const float bottom, const float top, const float nearClip, const float farClip);
+void orthographic_m4(float mat[4][4], const float left, const float right,
+ const float bottom, const float top, const float nearClip, const float farClip);
void window_translate_m4(float winmat[][4], float perspmat[][4],
- float x, float y);
+ const float x, const float y);
int box_clip_bounds_m4(float boundbox[2][3],
- float bounds[4], float winmat[4][4]);
+ const float bounds[4], float winmat[4][4]);
void box_minmax_bounds_m4(float min[3], float max[3],
float boundbox[2][3], float mat[4][4]);
/********************************** Mapping **********************************/
-void map_to_tube(float *u, float *v, float x, float y, float z);
-void map_to_sphere(float *u, float *v, float x, float y, float z);
+void map_to_tube(float *u, float *v, const float x, const float y, const float z);
+void map_to_sphere(float *u, float *v, const float x, const float y, const float z);
+
+/********************************** Normals **********************************/
+
+void accumulate_vertex_normals(float n1[3], float n2[3], float n3[3],
+ float n4[3], const float f_no[3], const float co1[3], const float co2[3],
+ const float co3[3], const float co4[3]);
/********************************* Tangents **********************************/
@@ -172,11 +187,11 @@ typedef struct VertexTangent {
float tang[3], uv[2];
} VertexTangent;
-float *find_vertex_tangent(VertexTangent *vtang, float *uv);
+float *find_vertex_tangent(VertexTangent *vtang, const float uv[2]);
void sum_or_add_vertex_tangent(void *arena, VertexTangent **vtang,
- float *tang, float *uv);
-void tangent_from_uv(float *uv1, float *uv2, float *uv3,
- float *co1, float *co2, float *co3, float *n, float *tang);
+ const float tang[3], const float uv[2]);
+void tangent_from_uv(float uv1[2], float uv2[2], float uv3[2],
+ float co1[3], float co2[3], float co3[3], float n[3], float tang[3]);
/******************************** Vector Clouds ******************************/
@@ -192,14 +207,14 @@ void vcloud_estimate_transform(int list_size, float (*pos)[3], float *weight,
4 = (2,-2), 5 = (2,-1), 6 = (2,0), 7 = (2,1), 8 = (2,2) */
MINLINE void zero_sh(float r[9]);
-MINLINE void copy_sh_sh(float r[9], float a[9]);
-MINLINE void mul_sh_fl(float r[9], float f);
-MINLINE void add_sh_shsh(float r[9], float a[9], float b[9]);
-
-MINLINE float eval_shv3(float r[9], float v[3]);
-MINLINE float diffuse_shv3(float r[9], float v[3]);
-MINLINE void vec_fac_to_sh(float r[9], float v[3], float f);
-MINLINE void madd_sh_shfl(float r[9], float sh[3], float f);
+MINLINE void copy_sh_sh(float r[9], const float a[9]);
+MINLINE void mul_sh_fl(float r[9], const float f);
+MINLINE void add_sh_shsh(float r[9], const float a[9], const float b[9]);
+
+MINLINE float eval_shv3(float r[9], const float v[3]);
+MINLINE float diffuse_shv3(float r[9], const float v[3]);
+MINLINE void vec_fac_to_sh(float r[9], const float v[3], const float f);
+MINLINE void madd_sh_shfl(float r[9], const float sh[3], const float f);
/********************************* Form Factor *******************************/
diff --git a/source/blender/blenlib/BLI_math_inline.h b/source/blender/blenlib/BLI_math_inline.h
index d07777c90a8..0f8493e25a6 100644
--- a/source/blender/blenlib/BLI_math_inline.h
+++ b/source/blender/blenlib/BLI_math_inline.h
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -28,6 +28,10 @@
#ifndef BLI_MATH_INLINE_H
#define BLI_MATH_INLINE_H
+/** \file BLI_math_inline.h
+ * \ingroup bli
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h
index 475bbe8b4b7..939c4348461 100644
--- a/source/blender/blenlib/BLI_math_matrix.h
+++ b/source/blender/blenlib/BLI_math_matrix.h
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -28,6 +28,10 @@
#ifndef BLI_MATH_MATRIX_H
#define BLI_MATH_MATRIX_H
+/** \file BLI_math_matrix.h
+ * \ingroup bli
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/source/blender/blenlib/BLI_math_rotation.h b/source/blender/blenlib/BLI_math_rotation.h
index 7d0b8dfeaf3..ee8c3d5e10c 100644
--- a/source/blender/blenlib/BLI_math_rotation.h
+++ b/source/blender/blenlib/BLI_math_rotation.h
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -28,6 +28,10 @@
#ifndef BLI_MATH_ROTATION_H
#define BLI_MATH_ROTATION_H
+/** \file BLI_math_rotation.h
+ * \ingroup bli
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -35,6 +39,10 @@ extern "C" {
#define RAD2DEG(_rad) ((_rad)*(180.0/M_PI))
#define DEG2RAD(_deg) ((_deg)*(M_PI/180.0))
+
+#define RAD2DEGF(_rad) ((_rad)*(float)(180.0/M_PI))
+#define DEG2RADF(_deg) ((_deg)*(float)(M_PI/180.0))
+
/******************************** Quaternions ********************************/
/* stored in (w, x, y, z) order */
@@ -81,7 +89,7 @@ void rotation_between_quats_to_quat(float q[4], const float q1[4], const float q
void mat3_to_quat_is_ok(float q[4], float mat[3][3]);
/* other */
-void print_qt(char *str, float q[4]);
+void print_qt(const char *str, const float q[4]);
/******************************** Axis Angle *********************************/
@@ -177,6 +185,9 @@ void vec_apply_track(float vec[3], short axis);
float lens_to_angle(float lens);
float angle_to_lens(float angle);
+float angle_wrap_rad(float angle);
+float angle_wrap_deg(float angle);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index dcb9311baa0..5f26bff0ad9 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -28,6 +28,10 @@
#ifndef BLI_MATH_VECTOR_H
#define BLI_MATH_VECTOR_H
+/** \file BLI_math_vector.h
+ * \ingroup bli
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/source/blender/blenlib/BLI_memarena.h b/source/blender/blenlib/BLI_memarena.h
index a17c88b70df..f6e919d8d65 100644
--- a/source/blender/blenlib/BLI_memarena.h
+++ b/source/blender/blenlib/BLI_memarena.h
@@ -1,6 +1,4 @@
/*
- * Memory arena ADT
- *
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -27,11 +25,15 @@
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
- *
+ */
+
+/** \file BLI_memarena.h
+ * \ingroup bli
+ * \brief Memory arena ADT.
+ * \section aboutmemarena Memory Arena
* Memory arena's are commonly used when the program
* needs to quickly allocate lots of little bits of
* data, which are all freed at the same moment.
- *
*/
#ifndef BLI_MEMARENA_H
diff --git a/source/blender/blenlib/BLI_mempool.h b/source/blender/blenlib/BLI_mempool.h
index 7c2dc36d533..4ea48929efb 100644
--- a/source/blender/blenlib/BLI_mempool.h
+++ b/source/blender/blenlib/BLI_mempool.h
@@ -1,7 +1,5 @@
-/**
- * Simple fast memory allocator
- *
- *
+/*
+ * $Id$
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -31,14 +29,18 @@
#ifndef BLI_MEMPOOL_H
#define BLI_MEMPOOL_H
-struct BLI_mempool;
-typedef struct BLI_mempool BLI_mempool;
+/** \file BLI_storage.h
+ * \ingroup bli
+ * \author Geoffrey Bantle
+ * \brief Simple fast memory allocator.
+ */
-BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk, int use_sysmalloc);
-void *BLI_mempool_alloc(BLI_mempool *pool);
-void *BLI_mempool_calloc(BLI_mempool *pool);
-void BLI_mempool_free(BLI_mempool *pool, void *addr);
-void BLI_mempool_destroy(BLI_mempool *pool);
+struct BLI_mempool;
+struct BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk, int use_sysmalloc);
+void *BLI_mempool_alloc(struct BLI_mempool *pool);
+void *BLI_mempool_calloc(struct BLI_mempool *pool);
+void BLI_mempool_free(struct BLI_mempool *pool, void *addr);
+void BLI_mempool_destroy(struct BLI_mempool *pool);
#endif
diff --git a/source/blender/blenlib/BLI_noise.h b/source/blender/blenlib/BLI_noise.h
index 11587262645..bd88529b3dc 100644
--- a/source/blender/blenlib/BLI_noise.h
+++ b/source/blender/blenlib/BLI_noise.h
@@ -31,6 +31,10 @@
#ifndef BLI_NOISE_H
#define BLI_NOISE_H
+/** \file BLI_noise.h
+ * \ingroup bli
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -57,7 +61,6 @@ void voronoi(float x, float y, float z, float* da, float* pa, float me, int dtyp
float cellNoise(float x, float y, float z);
void cellNoiseV(float x, float y, float z, float *ca);
-
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h
index 85286d15acb..dd4ae781832 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -1,8 +1,4 @@
-/**
- * blenlib/BLI_storage_types.h
- *
- * Some types for dealing with directories
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -33,6 +29,10 @@
#ifndef BLI_PATH_UTIL_H
#define BLI_PATH_UTIL_H
+/** \file BLI_path_util.h
+ * \ingroup bli
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -40,11 +40,12 @@ extern "C" {
struct ListBase;
struct direntry;
-char *BLI_getDefaultDocumentFolder(void);
+const char *BLI_getDefaultDocumentFolder(void);
char *BLI_get_folder(int folder_id, const char *subfolder);
char *BLI_get_folder_create(int folder_id, const char *subfolder);
char *BLI_get_user_folder_notest(int folder_id, const char *subfolder);
+char *BLI_get_folder_version(const int id, const int ver, const int do_check);
/* folder_id */
@@ -73,6 +74,11 @@ char *BLI_get_user_folder_notest(int folder_id, const char *subfolder);
#define BLENDER_USERFOLDER(id) (id >= BLENDER_USER_CONFIG && id <= BLENDER_USER_PLUGINS)
+/* for BLI_get_folder_version only */
+#define BLENDER_RESOURCE_PATH_USER 0
+#define BLENDER_RESOURCE_PATH_LOCAL 1
+#define BLENDER_RESOURCE_PATH_SYSTEM 2
+
#define BLENDER_STARTUP_FILE "startup.blend"
#define BLENDER_BOOKMARK_FILE "bookmarks.txt"
#define BLENDER_HISTORY_FILE "recent-files.txt"
@@ -103,19 +109,19 @@ void BLI_make_file_string(const char *relabase, char *string, const char *dir,
void BLI_make_exist(char *dir);
void BLI_make_existing_file(const char *name);
void BLI_split_dirfile(const char *string, char *dir, char *file);
-void BLI_join_dirfile(char *string, const char *dir, const char *file);
+void BLI_join_dirfile(char *string, const size_t maxlen, const char *dir, const char *file);
char *BLI_path_basename(char *path);
-int BKE_rebase_path(char *abs, int abs_size, char *rel, int rel_size, const char *base_dir, const char *src_dir, const char *dest_dir);
+int BKE_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const char *base_dir, const char *src_dir, const char *dest_dir);
char *BLI_last_slash(const char *string);
int BLI_add_slash(char *string);
void BLI_del_slash(char *string);
char *BLI_first_slash(char *string);
-void BLI_getlastdir(const char* dir, char *last, int maxlen);
+void BLI_getlastdir(const char* dir, char *last, const size_t maxlen);
int BLI_testextensie(const char *str, const char *ext);
int BLI_testextensie_array(const char *str, const char **ext_array);
int BLI_testextensie_glob(const char *str, const char *ext_fnmatch);
-int BLI_replace_extension(char *path, int maxlen, const char *ext);
+int BLI_replace_extension(char *path, size_t maxlen, const char *ext);
void BLI_uniquename(struct ListBase *list, void *vlink, const char defname[], char delim, short name_offs, short len);
int BLI_uniquename_cb(int (*unique_check)(void *, const char *), void *arg, const char defname[], char delim, char *name, short name_len);
void BLI_newname(char * name, int add);
@@ -132,8 +138,9 @@ void BLI_clean(char *path);
* converts it to a regular full path.
* Also removes garbage from directory paths, like /../ or double slashes etc
*/
-void BLI_cleanup_file(const char *relabase, char *dir);
+void BLI_cleanup_file(const char *relabase, char *dir); /* removes trailing slash */
void BLI_cleanup_dir(const char *relabase, char *dir); /* same as above but adds a trailing slash */
+void BLI_cleanup_path(const char *relabase, char *dir); /* doesn't touch trailing slash */
/* go back one directory */
int BLI_parent_dir(char *path);
@@ -157,9 +164,16 @@ int BLI_path_abs(char *path, const char *basepath);
int BLI_path_frame(char *path, int frame, int digits);
int BLI_path_frame_range(char *path, int sta, int end, int digits);
int BLI_path_cwd(char *path);
-
void BLI_path_rel(char *file, const char *relfile);
+#ifdef WIN32
+# define BLI_path_cmp BLI_strcasecmp
+# define BLI_path_ncmp BLI_strncasecmp
+#else
+# define BLI_path_cmp strcmp
+# define BLI_path_ncmp strncmp
+#endif
+
/**
* Change every @a from in @a string into @a to. The
* result will be in @a string
@@ -181,9 +195,8 @@ void BLI_char_switch(char *string, char from, char to);
* @param fullname The full path and full name of the executable
* @param name The name of the executable (usually argv[0]) to be checked
*/
-void BLI_where_am_i(char *fullname, const char *name);
+void BLI_where_am_i(char *fullname, const size_t maxlen, const char *name);
-char *get_install_dir(void);
/**
* Gets the temp directory when blender first runs.
* If the default path is not found, use try $TEMP
@@ -192,7 +205,7 @@ char *get_install_dir(void);
*
* @param fullname The full path to the temp directory
*/
-void BLI_where_is_temp(char *fullname, int usertemp);
+void BLI_where_is_temp(char *fullname, const size_t maxlen, int usertemp);
#ifdef WITH_ICONV
diff --git a/source/blender/blenlib/BLI_pbvh.h b/source/blender/blenlib/BLI_pbvh.h
index f89068c885e..89dcf9bf02d 100644
--- a/source/blender/blenlib/BLI_pbvh.h
+++ b/source/blender/blenlib/BLI_pbvh.h
@@ -1,6 +1,4 @@
-/**
- * A BVH for high poly meshes.
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -25,6 +23,11 @@
#ifndef BLI_PBVH_H
#define BLI_PBVH_H
+/** \file BLI_pbvh.h
+ * \ingroup bli
+ * \brief A BVH for high poly meshes.
+ */
+
struct MFace;
struct MVert;
struct DMGridAdjacency;
@@ -118,6 +121,8 @@ float BLI_pbvh_node_get_tmin(PBVHNode* node);
void BLI_pbvh_update(PBVH *bvh, int flags, float (*face_nors)[3]);
void BLI_pbvh_redraw_BB(PBVH *bvh, float bb_min[3], float bb_max[3]);
void BLI_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***gridfaces, int *totface);
+void BLI_pbvh_grids_update(PBVH *bvh, struct DMGridData **grids,
+ struct DMGridAdjacency *gridadj, void **gridfaces);
/* vertex deformer */
float (*BLI_pbvh_get_vertCos(struct PBVH *pbvh))[3];
diff --git a/source/blender/blenlib/BLI_rand.h b/source/blender/blenlib/BLI_rand.h
index eab9f92d7e8..eb6e71acded 100644
--- a/source/blender/blenlib/BLI_rand.h
+++ b/source/blender/blenlib/BLI_rand.h
@@ -1,7 +1,4 @@
-/**
- * @file BLI_rand.h
- *
- * Random number functions.
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -33,10 +30,15 @@
#ifndef BLI_RAND_H
#define BLI_RAND_H
- /* RNG is just an abstract random number generator
- * type that avoids using globals, otherwise identical
- * to BLI_rand functions below.
- */
+/** \file BLI_rand.h
+ * \ingroup bli
+ * \brief Random number functions.
+ */
+
+/** RNG is just an abstract random number generator
+ * type that avoids using globals, otherwise identical
+ * to BLI_rand functions below.
+ */
struct RNG;
typedef struct RNG RNG;
diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h
index 13b12fc4e1e..021ab636d5b 100644
--- a/source/blender/blenlib/BLI_rect.h
+++ b/source/blender/blenlib/BLI_rect.h
@@ -31,6 +31,10 @@
#ifndef BLI_RECT_H
#define BLI_RECT_H
+/** \file BLI_rect.h
+ * \ingroup bli
+ */
+
struct rctf;
struct rcti;
diff --git a/source/blender/blenlib/BLI_scanfill.h b/source/blender/blenlib/BLI_scanfill.h
index bae5375f757..e2f102c20eb 100644
--- a/source/blender/blenlib/BLI_scanfill.h
+++ b/source/blender/blenlib/BLI_scanfill.h
@@ -1,8 +1,4 @@
-/**
- * blenlib/BLI_scanfill.h mar 2001 Nzc
- *
- * Filling meshes.
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -34,6 +30,13 @@
#ifndef BLI_SCANFILL_H
#define BLI_SCANFILL_H
+/** \file BLI_storage.h
+ * \ingroup bli
+ * \since March 2001
+ * \author nzc
+ * \brief Filling meshes.
+ */
+
/**
* @attention Defined in scanfill.c
*/
@@ -61,7 +64,7 @@ void BLI_end_edgefill(void);
* @param f The function to use as callback
* @attention used in creator.c
*/
-void BLI_setErrorCallBack(void (*f)(char*));
+void BLI_setErrorCallBack(void (*f)(const char*));
/**
* Set a function to be able to interrupt the execution of processing
diff --git a/source/blender/blenlib/BLI_storage.h b/source/blender/blenlib/BLI_storage.h
index 0996b19a854..017f9877baf 100644
--- a/source/blender/blenlib/BLI_storage.h
+++ b/source/blender/blenlib/BLI_storage.h
@@ -29,6 +29,10 @@
#ifndef BLI_STORAGE_H
#define BLI_STORAGE_H
+/** \file BLI_storage.h
+ * \ingroup bli
+ */
+
#ifdef WIN32
/* for size_t, only needed on win32 for some reason */
#include <stddef.h>
@@ -44,7 +48,7 @@ int BLI_compare(struct direntry *entry1, struct direntry *entry2);
size_t BLI_filesize(int file);
size_t BLI_filepathsize(const char *path);
double BLI_diskfree(const char *dir);
-char *BLI_getwdN(const char *dir);
+char *BLI_getwdN(char *dir, const int maxncpy);
unsigned int BLI_getdir(const char *dirname, struct direntry **filelist);
/**
diff --git a/source/blender/blenlib/BLI_storage_types.h b/source/blender/blenlib/BLI_storage_types.h
index c041b33c6a4..07c0ceffeb5 100644
--- a/source/blender/blenlib/BLI_storage_types.h
+++ b/source/blender/blenlib/BLI_storage_types.h
@@ -1,8 +1,4 @@
-/**
- * blenlib/BLI_storage_types.h
- *
- * Some types for dealing with directories
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -33,6 +29,11 @@
#ifndef BLI_STORAGE_TYPES_H
#define BLI_STORAGE_TYPES_H
+/** \file BLI_storage_types.h
+ * \ingroup bli
+ * \brief Some types for dealing with directories.
+ */
+
#include <sys/stat.h>
#if defined(WIN32) && !defined(FREE_WINDOWS)
@@ -53,7 +54,7 @@ struct direntry{
#else
struct stat s;
#endif
- unsigned int flags;
+ unsigned int flags;
char size[16];
char mode1[4];
char mode2[4];
@@ -65,6 +66,7 @@ struct direntry{
void *poin;
int nr;
struct ImBuf *image;
+ unsigned int selflag; /* selection flag */
};
struct dirlink
diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h
index 01ad70c31fb..635c38e1d13 100644
--- a/source/blender/blenlib/BLI_string.h
+++ b/source/blender/blenlib/BLI_string.h
@@ -32,6 +32,10 @@
#ifndef BLI_STRING_H
#define BLI_STRING_H
+/** \file BLI_string.h
+ * \ingroup bli
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -54,7 +58,7 @@ char *BLI_strdup(const char *str);
* @param len The number of bytes to duplicate
* @retval Returns the duplicated string
*/
-char *BLI_strdupn(const char *str, int len);
+char *BLI_strdupn(const char *str, const size_t len);
/**
* Appends the two strings, and returns new mallocN'ed string
@@ -74,7 +78,7 @@ char *BLI_strdupcat(const char *str1, const char *str2);
* the size of dst)
* @retval Returns dst
*/
-char *BLI_strncpy(char *dst, const char *src, int maxncpy);
+char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy);
/* Makes a copy of the text within the "" that appear after some text 'blahblah'
* i.e. for string 'pose["apples"]' with prefix 'pose[', it should grab "apples"
@@ -102,9 +106,9 @@ char *BLI_replacestr(char *str, const char *oldText, const char *newText);
/*
* Replacement for snprintf
*/
-int BLI_snprintf(char *buffer, size_t count, const char *format, ...)
+size_t BLI_snprintf(char *buffer, size_t len, const char *format, ...)
#ifdef __GNUC__
-__attribute__ ((format (printf, 3, 4)));
+__attribute__ ((format (printf, 3, 4)))
#endif
;
@@ -114,7 +118,7 @@ __attribute__ ((format (printf, 3, 4)));
*/
char *BLI_sprintfN(const char *format, ...)
#ifdef __GNUC__
-__attribute__ ((format (printf, 1, 2)));
+__attribute__ ((format (printf, 1, 2)))
#endif
;
@@ -134,7 +138,7 @@ int BLI_strcaseeq(const char *a, const char *b);
char *BLI_strcasestr(const char *s, const char *find);
int BLI_strcasecmp(const char *s1, const char *s2);
-int BLI_strncasecmp(const char *s1, const char *s2, int n);
+int BLI_strncasecmp(const char *s1, const char *s2, size_t len);
int BLI_natstrcmp(const char *s1, const char *s2);
size_t BLI_strnlen(const char *str, size_t maxlen);
diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h
index ad968deb0c5..5bf5423d312 100644
--- a/source/blender/blenlib/BLI_threads.h
+++ b/source/blender/blenlib/BLI_threads.h
@@ -31,6 +31,10 @@
#ifndef BLI_THREADS_H
#define BLI_THREADS_H
+/** \file BLI_threads.h
+ * \ingroup bli
+ */
+
#include <pthread.h>
/* for tables, button in UI, etc */
diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h
index 7749aaf0a67..a376d048412 100644
--- a/source/blender/blenlib/BLI_utildefines.h
+++ b/source/blender/blenlib/BLI_utildefines.h
@@ -1,5 +1,5 @@
/*
- * $Id: BLI_utildefines.h 34198 2011-01-09 15:12:08Z campbellbarton $
+ * $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
@@ -30,6 +30,10 @@
#ifndef BLI_UTILDEFINES_H
#define BLI_UTILDEFINES_H
+/** \file BLI_utildefines.h
+ * \ingroup bli
+ */
+
#ifndef FALSE
#define FALSE 0
#endif
@@ -121,11 +125,15 @@
#define CLAMPTEST(a, b, c) if((b)<(c)) {CLAMP(a, b, c);} else {CLAMP(a, c, b);}
#define IS_EQ(a,b) ((fabs((double)(a)-(b)) >= (double) FLT_EPSILON) ? 0 : 1)
+#define IS_EQF(a,b) ((fabsf((float)(a)-(b)) >= (float) FLT_EPSILON) ? 0 : 1)
#define IS_EQT(a, b, c) ((a > b)? (((a-b) <= c)? 1:0) : ((((b-a) <= c)? 1:0)))
#define IN_RANGE(a, b, c) ((b < c)? ((b<a && a<c)? 1:0) : ((c<a && a<b)? 1:0))
#define IN_RANGE_INCL(a, b, c) ((b < c)? ((b<=a && a<=c)? 1:0) : ((c<=a && a<=b)? 1:0))
+/* array helpers */
+#define ARRAY_LAST_ITEM(arr_start, arr_dtype, elem_size, tot) (arr_dtype *)((char*)arr_start + (elem_size*(tot - 1)))
+#define ARRAY_HAS_ITEM(item, arr_start, arr_dtype, elem_size, tot) ((item >= arr_start) && (item <= ARRAY_LAST_ITEM(arr_start, arr_dtype, elem_size, tot)))
/* This one rotates the bytes in an int64, int (32) and short (16) */
#define SWITCH_INT64(a) { \
@@ -169,6 +177,11 @@
# define UNUSED(x) UNUSED_ ## x
#endif
+#ifdef __GNUC__
+# define WARN_UNUSED __attribute__((warn_unused_result))
+#else
+# define WARN_UNUSED
+#endif
/*little macro so inline keyword works*/
#if defined(_MSC_VER)
@@ -193,7 +206,7 @@
# ifdef __GNUC__ /* just want to check if __func__ is available */
# define BLI_assert(a) \
do { \
- if (0 == (a)) { \
+ if (!(a)) { \
fprintf(stderr, \
"BLI_assert failed: %s, %s(), %d at \'%s\'\n", \
__FILE__, __func__, __LINE__, STRINGIFY(a)); \
diff --git a/source/blender/blenlib/BLI_uvproject.h b/source/blender/blenlib/BLI_uvproject.h
index cf8bb7cd4b8..54e2090aa50 100644
--- a/source/blender/blenlib/BLI_uvproject.h
+++ b/source/blender/blenlib/BLI_uvproject.h
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -22,6 +22,10 @@
#ifndef BKE_UVPROJECT_H
#define BKE_UVPROJECT_H
+/** \file BLI_uvproject.h
+ * \ingroup bli
+ */
+
struct UvCameraInfo;
struct Object;
diff --git a/source/blender/blenlib/BLI_vfontdata.h b/source/blender/blenlib/BLI_vfontdata.h
index 77abb15b953..7a03c1c37fa 100644
--- a/source/blender/blenlib/BLI_vfontdata.h
+++ b/source/blender/blenlib/BLI_vfontdata.h
@@ -1,9 +1,4 @@
-/**
- * @file BLI_vfontdata.h
- *
- * A structure to represent vector fonts,
- * and to load them from PostScript fonts.
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -35,6 +30,12 @@
#ifndef BLI_VFONTDATA_H
#define BLI_VFONTDATA_H
+/** \file BLI_vfontdata.h
+ * \ingroup bli
+ * \brief A structure to represent vector fonts,
+ * and to load them from PostScript fonts.
+ */
+
#include "DNA_listBase.h"
struct PackedFile;
diff --git a/source/blender/blenlib/BLI_voxel.h b/source/blender/blenlib/BLI_voxel.h
index 63a6c09b0b4..41f8bfab729 100644
--- a/source/blender/blenlib/BLI_voxel.h
+++ b/source/blender/blenlib/BLI_voxel.h
@@ -1,5 +1,4 @@
-/**
- *
+/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -29,7 +28,11 @@
#ifndef BLI_VOXEL_H
#define BLI_VOXEL_H
-/* find the index number of a voxel, given x/y/z integer coords and resolution vector */
+/** \file BLI_voxel.h
+ * \ingroup bli
+ */
+
+/** find the index number of a voxel, given x/y/z integer coords and resolution vector */
#define V_I(x, y, z, res) ( (z)*(res)[1]*(res)[0] + (y)*(res)[0] + (x) )
/* all input coordinates must be in bounding box 0.0 - 1.0 */
diff --git a/source/blender/blenlib/BLI_winstuff.h b/source/blender/blenlib/BLI_winstuff.h
index 2b0f548f5dd..d0eb3c7d67d 100644
--- a/source/blender/blenlib/BLI_winstuff.h
+++ b/source/blender/blenlib/BLI_winstuff.h
@@ -1,6 +1,4 @@
-/**
- * Compatibility-like things for windows.
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -32,6 +30,11 @@
#ifndef __WINSTUFF_H__
#define __WINSTUFF_H__
+/** \file BLI_winstuff.h
+ * \ingroup bli
+ * \brief Compatibility-like things for windows.
+ */
+
#ifdef _WIN32
#ifndef FREE_WINDOWS
@@ -72,7 +75,7 @@
#undef small
-// These definitions are also in arithb for simplicity
+// These definitions are also in BLI_math for simplicity
#ifdef __cplusplus
extern "C" {
@@ -124,7 +127,7 @@ typedef struct _DIR {
struct dirent direntry;
} DIR;
-void RegisterBlendExtension(char * str);
+void RegisterBlendExtension(void);
DIR *opendir (const char *path);
struct dirent *readdir(DIR *dp);
int closedir (DIR *dp);
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index dc043c3a21e..b7827d62851 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -28,6 +28,7 @@ set(INC
.
../makesdna
../blenkernel
+ ../blenloader
../gpu
../../../intern/ghost
../../../intern/guardedalloc
@@ -87,6 +88,7 @@ set(SRC
BLI_bpath.h
BLI_cpu.h
BLI_dlrbTree.h
+ BLI_dynlib.h
BLI_dynstr.h
BLI_edgehash.h
BLI_editVert.h
@@ -126,13 +128,13 @@ set(SRC
BLI_vfontdata.h
BLI_voxel.h
BLI_winstuff.h
- PIL_dynlib.h
PIL_time.h
intern/BLI_callbacks.h
intern/dynamiclist.h
)
-if(CMAKE_SYSTEM_NAME MATCHES "Linux")
+if(WITH_BINRELOC)
+ add_definitions(-DWITH_BINRELOC)
list(APPEND INC "${BINRELOC_INC}")
endif()
diff --git a/source/blender/blenlib/PIL_time.h b/source/blender/blenlib/PIL_time.h
index 2d5948c4217..82869035d50 100644
--- a/source/blender/blenlib/PIL_time.h
+++ b/source/blender/blenlib/PIL_time.h
@@ -1,4 +1,4 @@
-/**
+/*
* @file PIL_time.h
*
* Platform independant time functions.
@@ -29,6 +29,11 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
+
+/** \file blender/blenlib/PIL_time.h
+ * \ingroup bli
+ */
+
#ifndef PIL_TIME_H
#define PIL_TIME_H
@@ -51,9 +56,29 @@ double PIL_check_seconds_timer (void);
*/
void PIL_sleep_ms (int ms);
+/** Utility defines for timing.
+ * requires BLI_utildefines.h for 'AT'
+ * TIMEIT_VALUE returns the time since TIMEIT_START was called.
+ */
+#define TIMEIT_START(var) \
+{ \
+ double _timeit_##var= PIL_check_seconds_timer(); \
+ printf("time start (" #var "): " AT "\n"); \
+ fflush(stdout); \
+ { \
+
+
+#define TIMEIT_VALUE(var) (float)(PIL_check_seconds_timer() - _timeit_##var)
+
+
+#define TIMEIT_END(var) \
+ } \
+ printf("time end (" #var "): %.6f" " " AT "\n", TIMEIT_VALUE(var)); \
+ fflush(stdout); \
+} \
+
#ifdef __cplusplus
}
#endif
-#endif
-
+#endif /* !PIL_TIME_H */
diff --git a/source/blender/blenlib/SConscript b/source/blender/blenlib/SConscript
index 78aecf9936b..00caf8cd01d 100644
--- a/source/blender/blenlib/SConscript
+++ b/source/blender/blenlib/SConscript
@@ -4,14 +4,15 @@ Import ('env')
sources = env.Glob('intern/*.c')
cflags=''
-incs = '. ../makesdna ../blenkernel #/intern/guardedalloc #/intern/ghost ../editors/include ../gpu'
+incs = '. ../makesdna ../blenkernel #/intern/guardedalloc #/intern/ghost ../editors/include ../gpu ../blenloader'
incs += ' ' + env['BF_FREETYPE_INC']
incs += ' ' + env['BF_ZLIB_INC']
-defs = ''
+defs = []
-if env['OURPLATFORM'] == 'linux2':
+if env['WITH_BF_BINRELOC']:
cflags='-pthread'
incs += ' ../../../extern/binreloc/include'
+ defs.append('WITH_BINRELOC')
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
incs += ' ' + env['BF_PTHREADS_INC']
diff --git a/source/blender/blenlib/intern/BLI_args.c b/source/blender/blenlib/intern/BLI_args.c
index ff41f76a1f9..7bc93a3d3a0 100644
--- a/source/blender/blenlib/intern/BLI_args.c
+++ b/source/blender/blenlib/intern/BLI_args.c
@@ -1,4 +1,4 @@
-/**
+/*
* A general argument parsing module
*
* $Id$
@@ -29,6 +29,11 @@
* ***** END GPL LICENSE BLOCK *****
*/
+/** \file blender/blenlib/intern/BLI_args.c
+ * \ingroup bli
+ */
+
+
#include <ctype.h> /* for tolower */
#include "MEM_guardedalloc.h"
@@ -39,7 +44,7 @@
#include "BLI_args.h"
#include "BLI_ghash.h"
-char NO_DOCS[] = "NO DOCUMENTATION SPECIFIED";
+static char NO_DOCS[] = "NO DOCUMENTATION SPECIFIED";
struct bArgDoc;
typedef struct bArgDoc {
@@ -67,7 +72,7 @@ struct bArgs {
ListBase docs;
GHash *items;
int argc;
- char **argv;
+ const char **argv;
int *passes;
};
@@ -113,7 +118,7 @@ static bArgument *lookUp(struct bArgs *ba, const char *arg, int pass, int case_s
return BLI_ghash_lookup(ba->items, &key);
}
-bArgs *BLI_argsInit(int argc, char **argv)
+bArgs *BLI_argsInit(int argc, const char **argv)
{
bArgs *ba = MEM_callocN(sizeof(bArgs), "bArgs");
ba->passes = MEM_callocN(sizeof(int) * argc, "bArgs passes");
@@ -146,7 +151,7 @@ void BLI_argsPrint(struct bArgs *ba)
}
}
-char **BLI_argsArgv(struct bArgs *ba)
+const char **BLI_argsArgv(struct bArgs *ba)
{
return ba->argv;
}
diff --git a/source/blender/blenlib/intern/BLI_callbacks.h b/source/blender/blenlib/intern/BLI_callbacks.h
index 56e6cdd428b..ad09339e61a 100644
--- a/source/blender/blenlib/intern/BLI_callbacks.h
+++ b/source/blender/blenlib/intern/BLI_callbacks.h
@@ -1,4 +1,4 @@
-/**
+/*
* blenlib/BLI_editVert.h mar 2001 Nzc
*
* These callbacks are needed in the lib
@@ -31,6 +31,11 @@
* ***** END GPL LICENSE BLOCK *****
*/
+/** \file blender/blenlib/intern/BLI_callbacks.h
+ * \ingroup bli
+ */
+
+
#ifndef BLI_CALLBACKS_H
#define BLI_CALLBACKS_H
diff --git a/source/blender/blenlib/intern/BLI_dynstr.c b/source/blender/blenlib/intern/BLI_dynstr.c
index 1dcc06d6665..7587a5195a2 100644
--- a/source/blender/blenlib/intern/BLI_dynstr.c
+++ b/source/blender/blenlib/intern/BLI_dynstr.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -28,6 +28,11 @@
* Dynamically sized string ADT
*/
+/** \file blender/blenlib/intern/BLI_dynstr.c
+ * \ingroup bli
+ */
+
+
#include <stdarg.h>
#include <string.h>
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c
index a8ca828aa66..ff08ef4dba9 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -28,6 +28,11 @@
* A general (pointer -> pointer) hash table ADT
*/
+/** \file blender/blenlib/intern/BLI_ghash.c
+ * \ingroup bli
+ */
+
+
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
@@ -90,7 +95,7 @@ void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreef
MEM_freeN(gh->buckets);
BLI_mempool_destroy(gh->entrypool);
- gh->buckets = 0;
+ gh->buckets = NULL;
gh->nentries = 0;
gh->nbuckets = 0;
MEM_freeN(gh);
@@ -170,7 +175,7 @@ unsigned int BLI_ghashutil_inthash(const void *ptr) {
key += ~(key << 9);
key ^= (key >> 17);
- return (unsigned int)(key & 0xffffffff);
+ return (unsigned int)(key & 0xffffffff);
}
int BLI_ghashutil_intcmp(const void *a, const void *b) {
diff --git a/source/blender/blenlib/intern/BLI_heap.c b/source/blender/blenlib/intern/BLI_heap.c
index f6616ecb06b..a0b71dbde0e 100644
--- a/source/blender/blenlib/intern/BLI_heap.c
+++ b/source/blender/blenlib/intern/BLI_heap.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -28,6 +28,11 @@
* A heap / priority queue ADT.
*/
+/** \file blender/blenlib/intern/BLI_heap.c
+ * \ingroup bli
+ */
+
+
#include <string.h>
#include "MEM_guardedalloc.h"
@@ -64,7 +69,7 @@ struct Heap {
/***/
-Heap *BLI_heap_new()
+Heap *BLI_heap_new(void)
{
Heap *heap = (Heap*)MEM_callocN(sizeof(Heap), "BLIHeap");
heap->bufsize = 1;
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c
index 4673462f58b..f8a85c8ba76 100644
--- a/source/blender/blenlib/intern/BLI_kdopbvh.c
+++ b/source/blender/blenlib/intern/BLI_kdopbvh.c
@@ -1,4 +1,4 @@
-/**
+/*
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
@@ -26,6 +26,11 @@
* ***** END GPL LICENSE BLOCK *****
*/
+/** \file blender/blenlib/intern/BLI_kdopbvh.c
+ * \ingroup bli
+ */
+
+
#include <assert.h>
#include "MEM_guardedalloc.h"
@@ -161,7 +166,8 @@ static float KDOP_AXES[13][3] =
heap[parent] = element; \
}
-int ADJUST_MEMORY(void *local_memblock, void **memblock, int new_size, int *max_size, int size_per_item)
+#if 0
+static int ADJUST_MEMORY(void *local_memblock, void **memblock, int new_size, int *max_size, int size_per_item)
{
int new_max_size = *max_size * 2;
void *new_memblock = NULL;
@@ -186,7 +192,7 @@ int ADJUST_MEMORY(void *local_memblock, void **memblock, int new_size, int *max_
else
return FALSE;
}
-
+#endif
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Introsort
@@ -1137,11 +1143,11 @@ BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, unsigned int
// check for compatibility of both trees (can't compare 14-DOP with 18-DOP)
if((tree1->axis != tree2->axis) && (tree1->axis == 14 || tree2->axis == 14) && (tree1->axis == 18 || tree2->axis == 18))
- return 0;
+ return NULL;
// fast check root nodes for collision before doing big splitting + traversal
if(!tree_overlap(tree1->nodes[tree1->totleaf], tree2->nodes[tree2->totleaf], MIN2(tree1->start_axis, tree2->start_axis), MIN2(tree1->stop_axis, tree2->stop_axis)))
- return 0;
+ return NULL;
data = MEM_callocN(sizeof(BVHOverlapData *)* tree1->tree_type, "BVHOverlapData_star");
diff --git a/source/blender/blenlib/intern/BLI_kdtree.c b/source/blender/blenlib/intern/BLI_kdtree.c
index 0d541c1fe37..713bfde3417 100644
--- a/source/blender/blenlib/intern/BLI_kdtree.c
+++ b/source/blender/blenlib/intern/BLI_kdtree.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -28,6 +28,11 @@
* ***** END GPL LICENSE BLOCK *****
*/
+/** \file blender/blenlib/intern/BLI_kdtree.c
+ * \ingroup bli
+ */
+
+
#include "MEM_guardedalloc.h"
@@ -255,7 +260,7 @@ static void add_nearest(KDTreeNearest *ptn, int *found, int n, int index, float
/* finds the nearest n entries in tree to specified coordinates */
int BLI_kdtree_find_n_nearest(KDTree *tree, int n, float *co, float *nor, KDTreeNearest *nearest)
{
- KDTreeNode *root, *node=0;
+ KDTreeNode *root, *node= NULL;
KDTreeNode **stack, *defaultstack[100];
float cur_dist;
int i, totstack, cur=0, found=0;
@@ -370,7 +375,7 @@ static void add_in_range(KDTreeNearest **ptn, int found, int *totfoundstack, int
}
int BLI_kdtree_range_search(KDTree *tree, float range, float *co, float *nor, KDTreeNearest **nearest)
{
- KDTreeNode *root, *node=0;
+ KDTreeNode *root, *node= NULL;
KDTreeNode **stack, *defaultstack[100];
KDTreeNearest *foundstack=NULL;
float range2 = range*range, dist2;
diff --git a/source/blender/blenlib/intern/BLI_linklist.c b/source/blender/blenlib/intern/BLI_linklist.c
index c903e66057e..2de1689713e 100644
--- a/source/blender/blenlib/intern/BLI_linklist.c
+++ b/source/blender/blenlib/intern/BLI_linklist.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -28,6 +28,11 @@
* Support for linked lists.
*/
+/** \file blender/blenlib/intern/BLI_linklist.c
+ * \ingroup bli
+ */
+
+
#include "MEM_guardedalloc.h"
#include "BLI_linklist.h"
#include "BLI_memarena.h"
diff --git a/source/blender/blenlib/intern/BLI_memarena.c b/source/blender/blenlib/intern/BLI_memarena.c
index de2a73e065f..6ce5621e30d 100644
--- a/source/blender/blenlib/intern/BLI_memarena.c
+++ b/source/blender/blenlib/intern/BLI_memarena.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -28,6 +28,11 @@
* Efficient memory allocation for lots of similar small chunks.
*/
+/** \file blender/blenlib/intern/BLI_memarena.c
+ * \ingroup bli
+ */
+
+
#include "MEM_guardedalloc.h"
diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c
index 823841ef152..84e6151abaa 100644
--- a/source/blender/blenlib/intern/BLI_mempool.c
+++ b/source/blender/blenlib/intern/BLI_mempool.c
@@ -1,4 +1,4 @@
-/**
+/*
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
@@ -26,12 +26,18 @@
* ***** END GPL LICENSE BLOCK *****
*/
+/** \file blender/blenlib/intern/BLI_mempool.c
+ * \ingroup bli
+ */
+
+
/*
Simple, fast memory allocator for allocating many elements of the same size.
*/
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
+#include "BLI_mempool.h"
#include <string.h>
typedef struct BLI_freenode{
diff --git a/source/blender/blenlib/intern/DLRB_tree.c b/source/blender/blenlib/intern/DLRB_tree.c
index 69c9cc7e522..590425a8f06 100644
--- a/source/blender/blenlib/intern/DLRB_tree.c
+++ b/source/blender/blenlib/intern/DLRB_tree.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -25,6 +25,11 @@
* ***** END GPL LICENSE BLOCK *****
*/
+/** \file blender/blenlib/intern/DLRB_tree.c
+ * \ingroup bli
+ */
+
+
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
diff --git a/source/blender/blenlib/intern/boxpack2d.c b/source/blender/blenlib/intern/boxpack2d.c
index 643dcb6efca..8c7e097d239 100644
--- a/source/blender/blenlib/intern/boxpack2d.c
+++ b/source/blender/blenlib/intern/boxpack2d.c
@@ -21,6 +21,11 @@
* ***** END GPL LICENSE BLOCK *****
*/
+/** \file blender/blenlib/intern/boxpack2d.c
+ * \ingroup bli
+ */
+
+
#include <stdlib.h> /* for qsort */
#include "MEM_guardedalloc.h"
@@ -169,7 +174,7 @@ void boxPack2D(boxPack *boxarray, const int len, float *tot_width, float *tot_he
vertex_pack_indices = MEM_mallocN( len*3*sizeof(int), "boxPack Indices");
for (box=boxarray, box_index=0, i=0; box_index < len; box_index++, box++) {
-
+
vert->blb = vert->brb = vert->tlb =\
vert->isect_cache[0] = vert->isect_cache[1] =\
vert->isect_cache[2] = vert->isect_cache[3] = NULL;
@@ -255,17 +260,17 @@ void boxPack2D(boxPack *boxarray, const int len, float *tot_width, float *tot_he
if (vert->free & quad_flags[j]) {
switch (j) {
case BL:
- SET_BOXRIGHT(box, vert->x);
- SET_BOXTOP(box, vert->y);
- break;
+ SET_BOXRIGHT(box, vert->x);
+ SET_BOXTOP(box, vert->y);
+ break;
case TR:
- SET_BOXLEFT(box, vert->x);
- SET_BOXBOTTOM(box, vert->y);
- break;
+ SET_BOXLEFT(box, vert->x);
+ SET_BOXBOTTOM(box, vert->y);
+ break;
case TL:
- SET_BOXRIGHT(box, vert->x);
- SET_BOXBOTTOM(box, vert->y);
- break;
+ SET_BOXRIGHT(box, vert->x);
+ SET_BOXBOTTOM(box, vert->y);
+ break;
case BR:
SET_BOXLEFT(box, vert->x);
SET_BOXTOP(box, vert->y);
diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c
index b145eabed94..a56b1392b69 100644
--- a/source/blender/blenlib/intern/bpath.c
+++ b/source/blender/blenlib/intern/bpath.c
@@ -1,4 +1,4 @@
-/**
+/*
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
@@ -26,6 +26,11 @@
* ***** END GPL LICENSE BLOCK *****
*/
+/** \file blender/blenlib/intern/bpath.c
+ * \ingroup bli
+ */
+
+
#include <sys/stat.h>
#include <string.h>
@@ -141,9 +146,11 @@ void BLI_bpathIterator_init(struct BPathIterator **bpi_pt, Main *bmain, const ch
BLI_bpathIterator_step(bpi);
}
-void BLI_bpathIterator_alloc(struct BPathIterator **bpi) {
+#if 0
+static void BLI_bpathIterator_alloc(struct BPathIterator **bpi) {
*bpi= MEM_mallocN(sizeof(BPathIterator), "BLI_bpathIterator_alloc");
}
+#endif
void BLI_bpathIterator_free(struct BPathIterator *bpi) {
if (bpi->seqdata.seqar)
@@ -192,7 +199,7 @@ const char* BLI_bpathIterator_getName(struct BPathIterator *bpi) {
int BLI_bpathIterator_getType(struct BPathIterator *bpi) {
return bpi->type;
}
-int BLI_bpathIterator_getPathMaxLen(struct BPathIterator *bpi) {
+unsigned int BLI_bpathIterator_getPathMaxLen(struct BPathIterator *bpi) {
return bpi->len;
}
const char* BLI_bpathIterator_getBasePath(struct BPathIterator *bpi) {
@@ -797,7 +804,7 @@ static int findFileRecursive(char *filename_new, const char *dirname, const char
dir= opendir(dirname);
- if (dir==0)
+ if (dir==NULL)
return 0;
if (*filesize == -1)
@@ -808,7 +815,7 @@ static int findFileRecursive(char *filename_new, const char *dirname, const char
if (strcmp(".", de->d_name)==0 || strcmp("..", de->d_name)==0)
continue;
- BLI_join_dirfile(path, dirname, de->d_name);
+ BLI_join_dirfile(path, sizeof(path), dirname, de->d_name);
if (stat(path, &status) != 0)
continue; /* cant stat, dont bother with this file, could print debug info here */
diff --git a/source/blender/blenlib/intern/cpu.c b/source/blender/blenlib/intern/cpu.c
index 65e6b34488c..860a0cae2d1 100644
--- a/source/blender/blenlib/intern/cpu.c
+++ b/source/blender/blenlib/intern/cpu.c
@@ -1,4 +1,4 @@
-/**
+/*
*
* $Id$
*
@@ -21,6 +21,11 @@
* ***** END GPL LICENSE BLOCK *****
*/
+/** \file blender/blenlib/intern/cpu.c
+ * \ingroup bli
+ */
+
+
#include "BLI_cpu.h"
int BLI_cpu_support_sse2(void)
diff --git a/source/blender/blenlib/intern/dynamiclist.h b/source/blender/blenlib/intern/dynamiclist.h
index 3bf6e54a79b..7b496a5fed5 100644
--- a/source/blender/blenlib/intern/dynamiclist.h
+++ b/source/blender/blenlib/intern/dynamiclist.h
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -26,6 +26,11 @@
* ***** END GPL LICENSE BLOCK *****
*/
+/** \file blender/blenlib/intern/dynamiclist.h
+ * \ingroup bli
+ */
+
+
#ifndef B_DYNAMIC_LIST_H
#define B_DYNAMIC_LIST_H
diff --git a/source/blender/blenlib/intern/dynlib.c b/source/blender/blenlib/intern/dynlib.c
index 76a8a571480..ae6589b6538 100644
--- a/source/blender/blenlib/intern/dynlib.c
+++ b/source/blender/blenlib/intern/dynlib.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -27,109 +27,105 @@
* ***** END GPL LICENSE BLOCK *****
*/
+/** \file blender/blenlib/intern/dynlib.c
+ * \ingroup bli
+ */
+
+#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
-#include "../PIL_dynlib.h"
+#include "MEM_guardedalloc.h"
-#if !defined(CHAR_MAX)
-#define CHAR_MAX 255
-#endif
+#include "BLI_dynlib.h"
+
+struct DynamicLibrary {
+ void *handle;
+};
-/*
- * XXX, should use mallocN so we can see
- * handle's not being released. fixme zr
- */
-
#ifdef WIN32
-#include <string.h>
-#include <stdio.h>
#include <windows.h>
-struct PILdynlib {
- void *handle;
-};
-
-PILdynlib *PIL_dynlib_open(char *name) {
+DynamicLibrary *BLI_dynlib_open(char *name)
+{
+ DynamicLibrary *lib;
void *handle= LoadLibrary(name);
- if (handle) {
- PILdynlib *lib= malloc(sizeof(*lib));
- lib->handle= handle;
-
- return lib;
- } else {
+ if(!handle)
return NULL;
- }
+
+ lib= MEM_callocN(sizeof(*lib), "Dynamic Library");
+ lib->handle= handle;
+
+ return lib;
}
-void *PIL_dynlib_find_symbol(PILdynlib* lib, const char *symname) {
+void *BLI_dynlib_find_symbol(DynamicLibrary *lib, const char *symname)
+{
return GetProcAddress(lib->handle, symname);
}
-char *PIL_dynlib_get_error_as_string(PILdynlib* lib) {
+char *BLI_dynlib_get_error_as_string(DynamicLibrary *lib)
+{
int err;
/* if lib is NULL reset the last error code */
err= GetLastError();
- if (!lib) SetLastError(ERROR_SUCCESS);
+ if(!lib)
+ SetLastError(ERROR_SUCCESS);
- if (err) {
+ if(err) {
static char buf[1024];
- if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- err,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- buf,
- sizeof(buf),
- NULL))
+ if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ buf, sizeof(buf), NULL))
return buf;
}
return NULL;
}
-void PIL_dynlib_close(PILdynlib *lib) {
+void BLI_dynlib_close(DynamicLibrary *lib)
+{
FreeLibrary(lib->handle);
-
- free(lib);
+ MEM_freeN(lib);
}
-#else /* Unix */
+#else /* Unix */
#include <dlfcn.h>
-struct PILdynlib {
- void *handle;
-};
-
-PILdynlib *PIL_dynlib_open(char *name) {
+DynamicLibrary *BLI_dynlib_open(char *name)
+{
+ DynamicLibrary *lib;
void *handle= dlopen(name, RTLD_LAZY);
- if (handle) {
- PILdynlib *lib= malloc(sizeof(*lib));
- lib->handle= handle;
-
- return lib;
- } else {
+ if(!handle)
return NULL;
- }
+
+ lib= MEM_callocN(sizeof(*lib), "Dynamic Library");
+ lib->handle= handle;
+
+ return lib;
}
-void *PIL_dynlib_find_symbol(PILdynlib* lib, const char *symname) {
+void *BLI_dynlib_find_symbol(DynamicLibrary *lib, const char *symname)
+{
return dlsym(lib->handle, symname);
}
-char *PIL_dynlib_get_error_as_string(PILdynlib* lib) {
+char *BLI_dynlib_get_error_as_string(DynamicLibrary *lib)
+{
(void)lib; /* unused */
return dlerror();
}
-void PIL_dynlib_close(PILdynlib *lib) {
+void BLI_dynlib_close(DynamicLibrary *lib)
+{
dlclose(lib->handle);
-
- free(lib);
+ MEM_freeN(lib);
}
#endif
diff --git a/source/blender/blenlib/intern/edgehash.c b/source/blender/blenlib/intern/edgehash.c
index 4f93abf8357..bcd6855f272 100644
--- a/source/blender/blenlib/intern/edgehash.c
+++ b/source/blender/blenlib/intern/edgehash.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -28,6 +28,11 @@
* A general (pointer -> pointer) hash table ADT
*/
+/** \file blender/blenlib/intern/edgehash.c
+ * \ingroup bli
+ */
+
+
#include <stdlib.h>
#include <string.h>
diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c
index 462e3ed9d01..2e0f4b483b1 100644
--- a/source/blender/blenlib/intern/fileops.c
+++ b/source/blender/blenlib/intern/fileops.c
@@ -27,6 +27,11 @@
* ***** END GPL LICENSE BLOCK *****
*/
+/** \file blender/blenlib/intern/fileops.c
+ * \ingroup bli
+ */
+
+
#include <string.h>
#include <stdio.h>
@@ -128,13 +133,13 @@ int BLI_is_writable(const char *filename)
int BLI_touch(const char *file)
{
- FILE *f = fopen(file,"r+b");
- if (f != NULL) {
+ FILE *f = fopen(file,"r+b");
+ if (f != NULL) {
char c = getc(f);
rewind(f);
putc(c,f);
} else {
- f = fopen(file,"wb");
+ f = fopen(file,"wb");
}
if (f) {
fclose(f);
@@ -220,7 +225,8 @@ int BLI_copy_fileops(const char *file, const char *to) {
int BLI_link(const char *file, const char *to) {
callLocalErrorCallBack("Linking files is unsupported on Windows");
-
+ (void)file;
+ (void)to;
return 1;
}
@@ -271,7 +277,7 @@ int BLI_rename(const char *from, const char *to) {
* timer, and... We implement a callback mechanism. The system will
* have to initialise the callback before the functions will work!
* */
-static char str[MAXPATHLEN+12];
+static char str[12 + (MAXPATHLEN * 2)];
int BLI_delete(const char *file, int dir, int recursive)
{
@@ -280,34 +286,34 @@ int BLI_delete(const char *file, int dir, int recursive)
}
else {
if (recursive) {
- sprintf(str, "/bin/rm -rf \"%s\"", file);
+ BLI_snprintf(str, sizeof(str), "/bin/rm -rf \"%s\"", file);
return system(str);
}
else if (dir) {
- sprintf(str, "/bin/rmdir \"%s\"", file);
+ BLI_snprintf(str, sizeof(str), "/bin/rmdir \"%s\"", file);
return system(str);
}
else {
- return remove(file); //sprintf(str, "/bin/rm -f \"%s\"", file);
+ return remove(file); //BLI_snprintf(str, sizeof(str), "/bin/rm -f \"%s\"", file);
}
}
return -1;
}
int BLI_move(const char *file, const char *to) {
- sprintf(str, "/bin/mv -f \"%s\" \"%s\"", file, to);
+ BLI_snprintf(str, sizeof(str), "/bin/mv -f \"%s\" \"%s\"", file, to);
return system(str);
}
int BLI_copy_fileops(const char *file, const char *to) {
- sprintf(str, "/bin/cp -rf \"%s\" \"%s\"", file, to);
+ BLI_snprintf(str, sizeof(str), "/bin/cp -rf \"%s\" \"%s\"", file, to);
return system(str);
}
int BLI_link(const char *file, const char *to) {
- sprintf(str, "/bin/ln -f \"%s\" \"%s\"", file, to);
+ BLI_snprintf(str, sizeof(str), "/bin/ln -f \"%s\" \"%s\"", file, to);
return system(str);
}
diff --git a/source/blender/blenlib/intern/fnmatch.c b/source/blender/blenlib/intern/fnmatch.c
index c44ee754110..ae04075bda6 100644
--- a/source/blender/blenlib/intern/fnmatch.c
+++ b/source/blender/blenlib/intern/fnmatch.c
@@ -1,3 +1,6 @@
+/** \file blender/blenlib/intern/fnmatch.c
+ * \ingroup bli
+ */
/* Copyright (C) 1991, 1992, 1993, 1996, 1997 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c
index 482ca1c01e5..0fe028eb3c0 100644
--- a/source/blender/blenlib/intern/freetypefont.c
+++ b/source/blender/blenlib/intern/freetypefont.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -30,6 +30,11 @@
* Code that uses exotic character maps is present but commented out.
*/
+/** \file blender/blenlib/intern/freetypefont.c
+ * \ingroup bli
+ */
+
+
#ifdef WIN32
#pragma warning (disable:4244)
#endif
@@ -83,10 +88,10 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf
// adjust font size
height= ((double) face->bbox.yMax - (double) face->bbox.yMin);
- if(height != 0.0)
- scale = 1.0 / height;
+ if(height != 0.0f)
+ scale = 1.0f / height;
else
- scale = 1.0 / 1000.0;
+ scale = 1.0f / 1000.0f;
//
// Generate the character 3D data
@@ -162,20 +167,20 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf
if(k < npoints[j] - 1 )
{
if( ftoutline.tags[l] == FT_Curve_Tag_Conic && ftoutline.tags[l+1] == FT_Curve_Tag_Conic) {
- dx = (ftoutline.points[l].x + ftoutline.points[l+1].x)* scale / 2.0;
- dy = (ftoutline.points[l].y + ftoutline.points[l+1].y)* scale / 2.0;
+ dx = (ftoutline.points[l].x + ftoutline.points[l+1].x)* scale / 2.0f;
+ dy = (ftoutline.points[l].y + ftoutline.points[l+1].y)* scale / 2.0f;
//left handle
- bezt->vec[0][0] = (dx + (2 * ftoutline.points[l].x)* scale) / 3.0;
- bezt->vec[0][1] = (dy + (2 * ftoutline.points[l].y)* scale) / 3.0;
+ bezt->vec[0][0] = (dx + (2 * ftoutline.points[l].x)* scale) / 3.0f;
+ bezt->vec[0][1] = (dy + (2 * ftoutline.points[l].y)* scale) / 3.0f;
//midpoint (virtual on-curve point)
bezt->vec[1][0] = dx;
bezt->vec[1][1] = dy;
//right handle
- bezt->vec[2][0] = (dx + (2 * ftoutline.points[l+1].x)* scale) / 3.0;
- bezt->vec[2][1] = (dy + (2 * ftoutline.points[l+1].y)* scale) / 3.0;
+ bezt->vec[2][0] = (dx + (2 * ftoutline.points[l+1].x)* scale) / 3.0f;
+ bezt->vec[2][1] = (dy + (2 * ftoutline.points[l+1].y)* scale) / 3.0f;
bezt->h1= bezt->h2= HD_ALIGN;
bezt->radius= 1.0f;
@@ -192,12 +197,12 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf
bezt->vec[0][1] = ftoutline.points[l-1].y* scale;
bezt->h1= HD_FREE;
} else if(ftoutline.tags[l - 1] == FT_Curve_Tag_Conic) {
- bezt->vec[0][0] = (ftoutline.points[l].x + (2 * ftoutline.points[l - 1].x))* scale / 3.0;
- bezt->vec[0][1] = (ftoutline.points[l].y + (2 * ftoutline.points[l - 1].y))* scale / 3.0;
+ bezt->vec[0][0] = (ftoutline.points[l].x + (2 * ftoutline.points[l - 1].x))* scale / 3.0f;
+ bezt->vec[0][1] = (ftoutline.points[l].y + (2 * ftoutline.points[l - 1].y))* scale / 3.0f;
bezt->h1= HD_FREE;
} else {
- bezt->vec[0][0] = ftoutline.points[l].x* scale - (ftoutline.points[l].x - ftoutline.points[l-1].x)* scale / 3.0;
- bezt->vec[0][1] = ftoutline.points[l].y* scale - (ftoutline.points[l].y - ftoutline.points[l-1].y)* scale / 3.0;
+ bezt->vec[0][0] = ftoutline.points[l].x* scale - (ftoutline.points[l].x - ftoutline.points[l-1].x)* scale / 3.0f;
+ bezt->vec[0][1] = ftoutline.points[l].y* scale - (ftoutline.points[l].y - ftoutline.points[l-1].y)* scale / 3.0f;
bezt->h1= HD_VECT;
}
} else { //first point on curve
@@ -206,12 +211,12 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf
bezt->vec[0][1] = ftoutline.points[ftoutline.contours[j]].y * scale;
bezt->h1= HD_FREE;
} else if(ftoutline.tags[ftoutline.contours[j]] == FT_Curve_Tag_Conic) {
- bezt->vec[0][0] = (ftoutline.points[l].x + (2 * ftoutline.points[ftoutline.contours[j]].x))* scale / 3.0 ;
- bezt->vec[0][1] = (ftoutline.points[l].y + (2 * ftoutline.points[ftoutline.contours[j]].y))* scale / 3.0 ;
+ bezt->vec[0][0] = (ftoutline.points[l].x + (2 * ftoutline.points[ftoutline.contours[j]].x))* scale / 3.0f;
+ bezt->vec[0][1] = (ftoutline.points[l].y + (2 * ftoutline.points[ftoutline.contours[j]].y))* scale / 3.0f;
bezt->h1= HD_FREE;
} else {
- bezt->vec[0][0] = ftoutline.points[l].x* scale - (ftoutline.points[l].x - ftoutline.points[ftoutline.contours[j]].x)* scale / 3.0;
- bezt->vec[0][1] = ftoutline.points[l].y* scale - (ftoutline.points[l].y - ftoutline.points[ftoutline.contours[j]].y)* scale / 3.0;
+ bezt->vec[0][0] = ftoutline.points[l].x* scale - (ftoutline.points[l].x - ftoutline.points[ftoutline.contours[j]].x)* scale / 3.0f;
+ bezt->vec[0][1] = ftoutline.points[l].y* scale - (ftoutline.points[l].y - ftoutline.points[ftoutline.contours[j]].y)* scale / 3.0f;
bezt->h1= HD_VECT;
}
}
@@ -227,12 +232,12 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf
bezt->vec[2][1] = ftoutline.points[l+1].y* scale;
bezt->h2= HD_FREE;
} else if(ftoutline.tags[l+1] == FT_Curve_Tag_Conic) {
- bezt->vec[2][0] = (ftoutline.points[l].x + (2 * ftoutline.points[l+1].x))* scale / 3.0;
- bezt->vec[2][1] = (ftoutline.points[l].y + (2 * ftoutline.points[l+1].y))* scale / 3.0;
+ bezt->vec[2][0] = (ftoutline.points[l].x + (2 * ftoutline.points[l+1].x))* scale / 3.0f;
+ bezt->vec[2][1] = (ftoutline.points[l].y + (2 * ftoutline.points[l+1].y))* scale / 3.0f;
bezt->h2= HD_FREE;
} else {
- bezt->vec[2][0] = ftoutline.points[l].x* scale - (ftoutline.points[l].x - ftoutline.points[l+1].x)* scale / 3.0;
- bezt->vec[2][1] = ftoutline.points[l].y* scale - (ftoutline.points[l].y - ftoutline.points[l+1].y)* scale / 3.0;
+ bezt->vec[2][0] = ftoutline.points[l].x* scale - (ftoutline.points[l].x - ftoutline.points[l+1].x)* scale / 3.0f;
+ bezt->vec[2][1] = ftoutline.points[l].y* scale - (ftoutline.points[l].y - ftoutline.points[l+1].y)* scale / 3.0f;
bezt->h2= HD_VECT;
}
} else { //last point on curve
@@ -241,12 +246,12 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf
bezt->vec[2][1] = ftoutline.points[m].y* scale;
bezt->h2= HD_FREE;
} else if(ftoutline.tags[m] == FT_Curve_Tag_Conic) {
- bezt->vec[2][0] = (ftoutline.points[l].x + (2 * ftoutline.points[m].x))* scale / 3.0 ;
- bezt->vec[2][1] = (ftoutline.points[l].y + (2 * ftoutline.points[m].y))* scale / 3.0 ;
+ bezt->vec[2][0] = (ftoutline.points[l].x + (2 * ftoutline.points[m].x))* scale / 3.0f;
+ bezt->vec[2][1] = (ftoutline.points[l].y + (2 * ftoutline.points[m].y))* scale / 3.0f;
bezt->h2= HD_FREE;
} else {
- bezt->vec[2][0] = ftoutline.points[l].x* scale - (ftoutline.points[l].x - ftoutline.points[m].x)* scale / 3.0;
- bezt->vec[2][1] = ftoutline.points[l].y* scale - (ftoutline.points[l].y - ftoutline.points[m].y)* scale / 3.0;
+ bezt->vec[2][0] = ftoutline.points[l].x* scale - (ftoutline.points[l].x - ftoutline.points[m].x)* scale / 3.0f;
+ bezt->vec[2][1] = ftoutline.points[l].y* scale - (ftoutline.points[l].y - ftoutline.points[m].y)* scale / 3.0f;
bezt->h2= HD_VECT;
}
}
@@ -256,10 +261,10 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf
// len_squared_v2v2, see if there's a distance between the three points
// len_squared_v2v2 again, to check the angle between the handles
// finally, check if one of them is a vector handle
- if((dist_to_line_v2(bezt->vec[0],bezt->vec[1],bezt->vec[2]) < 0.001) &&
- (len_squared_v2v2(bezt->vec[0], bezt->vec[1]) > 0.0001*0.0001) &&
- (len_squared_v2v2(bezt->vec[1], bezt->vec[2]) > 0.0001*0.0001) &&
- (len_squared_v2v2(bezt->vec[0], bezt->vec[2]) > 0.0002*0.0001) &&
+ if((dist_to_line_v2(bezt->vec[0],bezt->vec[1],bezt->vec[2]) < 0.001f) &&
+ (len_squared_v2v2(bezt->vec[0], bezt->vec[1]) > 0.0001f*0.0001f) &&
+ (len_squared_v2v2(bezt->vec[1], bezt->vec[2]) > 0.0001f*0.0001f) &&
+ (len_squared_v2v2(bezt->vec[0], bezt->vec[2]) > 0.0002f*0.0001f) &&
(len_squared_v2v2(bezt->vec[0], bezt->vec[2]) > MAX2(len_squared_v2v2(bezt->vec[0], bezt->vec[1]), len_squared_v2v2(bezt->vec[1], bezt->vec[2]))) &&
bezt->h1 != HD_VECT && bezt->h2 != HD_VECT)
{
@@ -367,7 +372,7 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile * pf)
// No charmap found from the ttf so we need to figure it out
if(glyph_index == 0)
{
- FT_CharMap found = 0;
+ FT_CharMap found = NULL;
FT_CharMap charmap;
int n;
@@ -477,7 +482,7 @@ VFontData *BLI_vfontdata_from_freetypefont(PackedFile *pf)
err = FT_Init_FreeType( &library);
if(err) {
//XXX error("Failed to load the Freetype font library");
- return 0;
+ return NULL;
}
success = check_freetypefont(pf);
diff --git a/source/blender/blenlib/intern/graph.c b/source/blender/blenlib/intern/graph.c
index e187595aa11..51e639d1c75 100644
--- a/source/blender/blenlib/intern/graph.c
+++ b/source/blender/blenlib/intern/graph.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -23,6 +23,11 @@
* graph.c: Common graph interface and methods
*/
+/** \file blender/blenlib/intern/graph.c
+ * \ingroup bli
+ */
+
+
#include <float.h>
#include <math.h>
@@ -296,7 +301,7 @@ BNode * BLI_FindNodeByPosition(BGraph *graph, float *p, float limit)
}
/************************************* SUBGRAPH DETECTION **********************************************/
-void flagSubgraph(BNode *node, int subgraph)
+static void flagSubgraph(BNode *node, int subgraph)
{
if (node->subgraph_index == 0)
{
@@ -425,7 +430,7 @@ BArc * BLI_findConnectedArc(BGraph *graph, BArc *arc, BNode *v)
/*********************************** GRAPH AS TREE FUNCTIONS *******************************************/
-int subtreeShape(BNode *node, BArc *rootArc, int include_root)
+static int subtreeShape(BNode *node, BArc *rootArc, int include_root)
{
int depth = 0;
diff --git a/source/blender/blenlib/intern/gsqueue.c b/source/blender/blenlib/intern/gsqueue.c
index a8b40e187d8..e6f27c78bf1 100644
--- a/source/blender/blenlib/intern/gsqueue.c
+++ b/source/blender/blenlib/intern/gsqueue.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -26,6 +26,11 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
+
+/** \file blender/blenlib/intern/gsqueue.c
+ * \ingroup bli
+ */
+
#include <string.h>
#include "MEM_guardedalloc.h"
diff --git a/source/blender/blenlib/intern/jitter.c b/source/blender/blenlib/intern/jitter.c
index dfc554394d6..16f0c86c449 100644
--- a/source/blender/blenlib/intern/jitter.c
+++ b/source/blender/blenlib/intern/jitter.c
@@ -1,4 +1,4 @@
-/**
+/*
* Jitter offset table
*
* $Id$
@@ -29,11 +29,17 @@
* ***** END GPL LICENSE BLOCK *****
*/
+/** \file blender/blenlib/intern/jitter.c
+ * \ingroup bli
+ */
+
+
#include <math.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "BLI_rand.h"
+#include "BLI_jitter.h"
void BLI_jitterate1(float *jit1, float *jit2, int num, float rad1)
diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c
index b8b0b5b6eda..05f71e0c01f 100644
--- a/source/blender/blenlib/intern/listbase.c
+++ b/source/blender/blenlib/intern/listbase.c
@@ -32,6 +32,11 @@
*
*/
+/** \file blender/blenlib/intern/listbase.c
+ * \ingroup bli
+ */
+
+
#include <string.h>
#include <stdlib.h>
@@ -48,9 +53,9 @@
/* Ripped this from blender.c */
void BLI_movelisttolist(ListBase *dst, ListBase *src)
{
- if (src->first==0) return;
+ if (src->first==NULL) return;
- if (dst->first==0) {
+ if (dst->first==NULL) {
dst->first= src->first;
dst->last= src->last;
}
@@ -59,7 +64,7 @@ void BLI_movelisttolist(ListBase *dst, ListBase *src)
((Link *)src->first)->prev= dst->last;
dst->last= src->last;
}
- src->first= src->last= 0;
+ src->first= src->last= NULL;
}
void BLI_addhead(ListBase *listbase, void *vlink)
@@ -89,7 +94,7 @@ void BLI_addtail(ListBase *listbase, void *vlink)
link->prev = listbase->last;
if (listbase->last) ((Link *)listbase->last)->next = link;
- if (listbase->first == 0) listbase->first = link;
+ if (listbase->first == NULL) listbase->first = link;
listbase->last = link;
}
@@ -152,7 +157,7 @@ void BLI_insertlink(ListBase *listbase, void *vprevlink, void *vnewlink)
/* insert before first element */
if (prevlink == NULL) {
newlink->next= listbase->first;
- newlink->prev= 0;
+ newlink->prev= NULL;
newlink->next->prev= newlink;
listbase->first= newlink;
return;
@@ -251,7 +256,7 @@ void BLI_insertlinkbefore(ListBase *listbase, void *vnextlink, void *vnewlink)
/* insert at end of list */
if (nextlink == NULL) {
newlink->prev= listbase->last;
- newlink->next= 0;
+ newlink->next= NULL;
((Link *)listbase->last)->next= newlink;
listbase->last= newlink;
return;
@@ -361,14 +366,30 @@ void *BLI_findstring(const ListBase *listbase, const char *id, const int offset)
if (listbase == NULL) return NULL;
- link= listbase->first;
- while (link) {
+ for (link= listbase->first; link; link= link->next) {
id_iter= ((const char *)link) + offset;
- if(id[0] == id_iter[0] && strcmp(id, id_iter)==0)
+ if (id[0] == id_iter[0] && strcmp(id, id_iter)==0) {
return link;
+ }
+ }
- link= link->next;
+ return NULL;
+}
+/* same as above but find reverse */
+void *BLI_rfindstring(const ListBase *listbase, const char *id, const int offset)
+{
+ Link *link= NULL;
+ const char *id_iter;
+
+ if (listbase == NULL) return NULL;
+
+ for (link= listbase->last; link; link= link->prev) {
+ id_iter= ((const char *)link) + offset;
+
+ if (id[0] == id_iter[0] && strcmp(id, id_iter)==0) {
+ return link;
+ }
}
return NULL;
@@ -381,15 +402,32 @@ void *BLI_findstring_ptr(const ListBase *listbase, const char *id, const int off
if (listbase == NULL) return NULL;
- link= listbase->first;
- while (link) {
+ for (link= listbase->first; link; link= link->next) {
/* exact copy of BLI_findstring(), except for this line */
id_iter= *((const char **)(((const char *)link) + offset));
- if(id[0] == id_iter[0] && strcmp(id, id_iter)==0)
+ if (id[0] == id_iter[0] && strcmp(id, id_iter)==0) {
return link;
+ }
+ }
- link= link->next;
+ return NULL;
+}
+/* same as above but find reverse */
+void *BLI_rfindstring_ptr(const ListBase *listbase, const char *id, const int offset)
+{
+ Link *link= NULL;
+ const char *id_iter;
+
+ if (listbase == NULL) return NULL;
+
+ for (link= listbase->last; link; link= link->prev) {
+ /* exact copy of BLI_rfindstring(), except for this line */
+ id_iter= *((const char **)(((const char *)link) + offset));
+
+ if (id[0] == id_iter[0] && strcmp(id, id_iter)==0) {
+ return link;
+ }
}
return NULL;
@@ -422,7 +460,7 @@ void BLI_duplicatelist(ListBase *dst, const ListBase *src)
/* in this order, to ensure it works if dst == src */
src_link= src->first;
- dst->first= dst->last= 0;
+ dst->first= dst->last= NULL;
while(src_link) {
dst_link= MEM_dupallocN(src_link);
diff --git a/source/blender/blenlib/intern/math_base.c b/source/blender/blenlib/intern/math_base.c
index df8749c9ddd..0e122a23faa 100644
--- a/source/blender/blenlib/intern/math_base.c
+++ b/source/blender/blenlib/intern/math_base.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -25,6 +25,11 @@
* ***** END GPL LICENSE BLOCK *****
* */
+/** \file blender/blenlib/intern/math_base.c
+ * \ingroup bli
+ */
+
+
#include "BLI_math.h"
diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c
index e54b84d7aaf..d37f1d6c5f0 100644
--- a/source/blender/blenlib/intern/math_base_inline.c
+++ b/source/blender/blenlib/intern/math_base_inline.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -25,6 +25,11 @@
* ***** END GPL LICENSE BLOCK *****
* */
+/** \file blender/blenlib/intern/math_base_inline.c
+ * \ingroup bli
+ */
+
+
#include <float.h>
#include <stdio.h>
#include <stdlib.h>
@@ -40,7 +45,7 @@
MINLINE float sqrt3f(float f)
{
- if(f==0.0) return 0;
+ if(f==0.0f) return 0.0f;
if(f<0) return (float)(-exp(log(-f)/3));
else return (float)(exp(log(f)/3));
}
@@ -68,7 +73,7 @@ MINLINE float saasin(float fac)
MINLINE float sasqrt(float fac)
{
- if(fac<=0.0) return 0.0;
+ if(fac<=0.0f) return 0.0f;
return (float)sqrt(fac);
}
@@ -88,7 +93,7 @@ MINLINE float saasinf(float fac)
MINLINE float sasqrtf(float fac)
{
- if(fac<=0.0) return 0.0;
+ if(fac<=0.0f) return 0.0f;
return (float)sqrtf(fac);
}
@@ -103,7 +108,7 @@ MINLINE float interpf(float target, float origin, float fac)
* the distance gets very high, 180d would be inf, but this case isn't valid */
MINLINE float shell_angle_to_dist(const float angle)
{
- return (angle < SMALL_NUMBER) ? 1.0f : fabsf(1.0f / cosf(angle));
+ return (angle < (float)SMALL_NUMBER) ? 1.0f : fabsf(1.0f / cosf(angle));
}
/* used for zoom values*/
diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c
index 0408d814d81..512086f0e17 100644
--- a/source/blender/blenlib/intern/math_color.c
+++ b/source/blender/blenlib/intern/math_color.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -25,6 +25,11 @@
* ***** END GPL LICENSE BLOCK *****
* */
+/** \file blender/blenlib/intern/math_color.c
+ * \ingroup bli
+ */
+
+
#include <assert.h>
#include "BLI_math.h"
@@ -40,9 +45,9 @@ void hsv_to_rgb(float h, float s, float v, float *r, float *g, float *b)
*b = v;
}
else {
- h= (h - floor(h))*6.0f;
+ h= (h - floorf(h))*6.0f;
- i = (int)floor(h);
+ i = (int)floorf(h);
f = h - i;
p = v*(1.0f-s);
q = v*(1.0f-(s*f));
@@ -303,11 +308,11 @@ unsigned int rgb_to_cpack(float r, float g, float b)
{
int ir, ig, ib;
- ir= (int)floor(255.0*r);
+ ir= (int)floor(255.0f*r);
if(ir<0) ir= 0; else if(ir>255) ir= 255;
- ig= (int)floor(255.0*g);
+ ig= (int)floor(255.0f*g);
if(ig<0) ig= 0; else if(ig>255) ig= 255;
- ib= (int)floor(255.0*b);
+ ib= (int)floor(255.0f*b);
if(ib<0) ib= 0; else if(ib>255) ib= 255;
return (ir+ (ig*256) + (ib*256*256));
@@ -337,9 +342,9 @@ void rgb_float_to_byte(const float *in, unsigned char *out)
{
int r, g, b;
- r= (int)(in[0] * 255.0);
- g= (int)(in[1] * 255.0);
- b= (int)(in[2] * 255.0);
+ r= (int)(in[0] * 255.0f);
+ g= (int)(in[1] * 255.0f);
+ b= (int)(in[2] * 255.0f);
out[0]= (char)((r <= 0)? 0 : (r >= 255)? 255 : r);
out[1]= (char)((g <= 0)? 0 : (g >= 255)? 255 : g);
@@ -458,14 +463,14 @@ int constrain_rgb(float *r, float *g, float *b)
float w;
/* Amount of white needed is w = - min(0, *r, *g, *b) */
-
+
w = (0 < *r) ? 0 : *r;
w = (w < *g) ? w : *g;
w = (w < *b) ? w : *b;
w = -w;
/* Add just enough white to make r, g, b all positive. */
-
+
if (w > 0) {
*r += w; *g += w; *b += w;
return 1; /* Color modified to fit RGB gamut */
@@ -504,8 +509,8 @@ void rgb_float_set_hue_float_offset(float rgb[3], float hue_offset)
rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
hsv[0]+= hue_offset;
- if(hsv[0]>1.0) hsv[0]-=1.0;
- else if(hsv[0]<0.0) hsv[0]+= 1.0;
+ if(hsv[0] > 1.0f) hsv[0] -= 1.0f;
+ else if(hsv[0] < 0.0f) hsv[0] += 1.0f;
hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2);
}
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index d7a71f8567c..be7f2d95d04 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -25,6 +25,11 @@
* ***** END GPL LICENSE BLOCK *****
* */
+/** \file blender/blenlib/intern/math_geom.c
+ * \ingroup bli
+ */
+
+
#include "MEM_guardedalloc.h"
@@ -36,14 +41,14 @@
/********************************** Polygons *********************************/
-void cent_tri_v3(float *cent, float *v1, float *v2, float *v3)
+void cent_tri_v3(float cent[3], const float v1[3], const float v2[3], const float v3[3])
{
cent[0]= 0.33333f*(v1[0]+v2[0]+v3[0]);
cent[1]= 0.33333f*(v1[1]+v2[1]+v3[1]);
cent[2]= 0.33333f*(v1[2]+v2[2]+v3[2]);
}
-void cent_quad_v3(float *cent, float *v1, float *v2, float *v3, float *v4)
+void cent_quad_v3(float cent[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3])
{
cent[0]= 0.25f*(v1[0]+v2[0]+v3[0]+v4[0]);
cent[1]= 0.25f*(v1[1]+v2[1]+v3[1]+v4[1]);
@@ -89,12 +94,12 @@ float normal_quad_v3(float n[3], const float v1[3], const float v2[3], const flo
float area_tri_v2(const float v1[2], const float v2[2], const float v3[2])
{
- return (float)(0.5f*fabs((v1[0]-v2[0])*(v2[1]-v3[1]) + (v1[1]-v2[1])*(v3[0]-v2[0])));
+ return 0.5f * fabsf((v1[0]-v2[0])*(v2[1]-v3[1]) + (v1[1]-v2[1])*(v3[0]-v2[0]));
}
float area_tri_signed_v2(const float v1[2], const float v2[2], const float v3[2])
{
- return (float)(0.5f*((v1[0]-v2[0])*(v2[1]-v3[1]) + (v1[1]-v2[1])*(v3[0]-v2[0])));
+ return 0.5f * ((v1[0]-v2[0])*(v2[1]-v3[1]) + (v1[1]-v2[1])*(v3[0]-v2[0]));
}
float area_quad_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3]) /* only convex Quadrilaterals */
@@ -126,7 +131,7 @@ float area_tri_v3(const float v1[3], const float v2[3], const float v3[3]) /* T
return (len/2.0f);
}
-float area_poly_v3(int nr, float verts[][3], float *normal)
+float area_poly_v3(int nr, float verts[][3], const float normal[3])
{
float x, y, z, area, max;
float *cur, *prev;
@@ -153,14 +158,14 @@ float area_poly_v3(int nr, float verts[][3], float *normal)
cur= verts[a+1];
}
- return (float)fabs(0.5*area/max);
+ return fabsf(0.5f * area / max);
}
/********************************* Distance **********************************/
/* distance v1 to line v2-v3 */
/* using Hesse formula, NO LINE PIECE! */
-float dist_to_line_v2(float *v1, float *v2, float *v3)
+float dist_to_line_v2(const float v1[2], const float v2[2], const float v3[2])
{
float a[2],deler;
@@ -169,30 +174,30 @@ float dist_to_line_v2(float *v1, float *v2, float *v3)
deler= (float)sqrt(a[0]*a[0]+a[1]*a[1]);
if(deler== 0.0f) return 0;
- return (float)(fabs((v1[0]-v2[0])*a[0]+(v1[1]-v2[1])*a[1])/deler);
+ return fabsf((v1[0]-v2[0])*a[0]+(v1[1]-v2[1])*a[1])/deler;
}
/* distance v1 to line-piece v2-v3 */
-float dist_to_line_segment_v2(float *v1, float *v2, float *v3)
+float dist_to_line_segment_v2(const float v1[2], const float v2[2], const float v3[2])
{
float labda, rc[2], pt[2], len;
rc[0]= v3[0]-v2[0];
rc[1]= v3[1]-v2[1];
len= rc[0]*rc[0]+ rc[1]*rc[1];
- if(len==0.0) {
+ if(len==0.0f) {
rc[0]= v1[0]-v2[0];
rc[1]= v1[1]-v2[1];
return (float)(sqrt(rc[0]*rc[0]+ rc[1]*rc[1]));
}
labda= (rc[0]*(v1[0]-v2[0]) + rc[1]*(v1[1]-v2[1]))/len;
- if(labda<=0.0) {
+ if(labda <= 0.0f) {
pt[0]= v2[0];
pt[1]= v2[1];
}
- else if(labda>=1.0) {
+ else if(labda >= 1.0f) {
pt[0]= v3[0];
pt[1]= v3[1];
}
@@ -203,11 +208,11 @@ float dist_to_line_segment_v2(float *v1, float *v2, float *v3)
rc[0]= pt[0]-v1[0];
rc[1]= pt[1]-v1[1];
- return (float)sqrt(rc[0]*rc[0]+ rc[1]*rc[1]);
+ return sqrtf(rc[0]*rc[0]+ rc[1]*rc[1]);
}
/* point closest to v1 on line v2-v3 in 3D */
-void closest_to_line_segment_v3(float *closest, float v1[3], float v2[3], float v3[3])
+void closest_to_line_segment_v3(float closest[3], const float v1[3], const float v2[3], const float v3[3])
{
float lambda, cp[3];
@@ -222,7 +227,7 @@ void closest_to_line_segment_v3(float *closest, float v1[3], float v2[3], float
}
/* distance v1 to line-piece v2-v3 in 3D */
-float dist_to_line_segment_v3(float *v1, float *v2, float *v3)
+float dist_to_line_segment_v3(const float v1[3], const float v2[3], const float v3[3])
{
float closest[3];
@@ -234,7 +239,7 @@ float dist_to_line_segment_v3(float *v1, float *v2, float *v3)
/******************************* Intersection ********************************/
/* intersect Line-Line, shorts */
-int isect_line_line_v2_short(const short *v1, const short *v2, const short *v3, const short *v4)
+int isect_line_line_v2_short(const short v1[2], const short v2[2], const short v3[2], const short v4[2])
{
float div, labda, mu;
@@ -253,19 +258,19 @@ int isect_line_line_v2_short(const short *v1, const short *v2, const short *v3,
}
/* intersect Line-Line, floats */
-int isect_line_line_v2(const float *v1, const float *v2, const float *v3, const float *v4)
+int isect_line_line_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
{
float div, labda, mu;
div= (v2[0]-v1[0])*(v4[1]-v3[1])-(v2[1]-v1[1])*(v4[0]-v3[0]);
- if(div==0.0) return ISECT_LINE_LINE_COLINEAR;
+ if(div==0.0f) return ISECT_LINE_LINE_COLINEAR;
labda= ((float)(v1[1]-v3[1])*(v4[0]-v3[0])-(v1[0]-v3[0])*(v4[1]-v3[1]))/div;
mu= ((float)(v1[1]-v3[1])*(v2[0]-v1[0])-(v1[0]-v3[0])*(v2[1]-v1[1]))/div;
- if(labda>=0.0 && labda<=1.0 && mu>=0.0 && mu<=1.0) {
- if(labda==0.0 || labda==1.0 || mu==0.0 || mu==1.0) return ISECT_LINE_LINE_EXACT;
+ if(labda>=0.0f && labda<=1.0f && mu>=0.0f && mu<=1.0f) {
+ if(labda==0.0f || labda==1.0f || mu==0.0f || mu==1.0f) return ISECT_LINE_LINE_EXACT;
return ISECT_LINE_LINE_CROSS;
}
return ISECT_LINE_LINE_NONE;
@@ -274,7 +279,7 @@ int isect_line_line_v2(const float *v1, const float *v2, const float *v3, const
/* get intersection point of two 2D segments and return intersection type:
-1: colliniar
1: intersection */
-int isect_seg_seg_v2_point(const float *v1, const float *v2, const float *v3, const float *v4, float vi[2])
+int isect_seg_seg_v2_point(const float v1[2], const float v2[2], const float v3[2], const float v4[2], float vi[2])
{
float a1, a2, b1, b2, c1, c2, d;
float u, v;
@@ -349,8 +354,8 @@ int isect_seg_seg_v2_point(const float *v1, const float *v2, const float *v3, co
1: intersection
*/
-static short IsectLLPt2Df(float x0,float y0,float x1,float y1,
- float x2,float y2,float x3,float y3, float *xi,float *yi)
+static short IsectLLPt2Df(const float x0, const float y0, const float x1, const float y1,
+ const float x2, const float y2, const float x3, const float y3, float *xi,float *yi)
{
/*
@@ -400,17 +405,17 @@ static short IsectLLPt2Df(float x0,float y0,float x1,float y1,
/* point in tri */
-int isect_point_tri_v2(float pt[2], float v1[2], float v2[2], float v3[2])
+int isect_point_tri_v2(const float pt[2], const float v1[2], const float v2[2], const float v3[2])
{
- if (line_point_side_v2(v1,v2,pt)>=0.0) {
- if (line_point_side_v2(v2,v3,pt)>=0.0) {
- if (line_point_side_v2(v3,v1,pt)>=0.0) {
+ if (line_point_side_v2(v1,v2,pt)>=0.0f) {
+ if (line_point_side_v2(v2,v3,pt)>=0.0f) {
+ if (line_point_side_v2(v3,v1,pt)>=0.0f) {
return 1;
}
}
} else {
- if (! (line_point_side_v2(v2,v3,pt)>=0.0)) {
- if (! (line_point_side_v2(v3,v1,pt)>=0.0)) {
+ if (! (line_point_side_v2(v2,v3,pt)>=0.0f)) {
+ if (! (line_point_side_v2(v3,v1,pt)>=0.0f)) {
return -1;
}
}
@@ -419,20 +424,20 @@ int isect_point_tri_v2(float pt[2], float v1[2], float v2[2], float v3[2])
return 0;
}
/* point in quad - only convex quads */
-int isect_point_quad_v2(float pt[2], float v1[2], float v2[2], float v3[2], float v4[2])
+int isect_point_quad_v2(const float pt[2], const float v1[2], const float v2[2], const float v3[2], const float v4[2])
{
- if (line_point_side_v2(v1,v2,pt)>=0.0) {
- if (line_point_side_v2(v2,v3,pt)>=0.0) {
- if (line_point_side_v2(v3,v4,pt)>=0.0) {
- if (line_point_side_v2(v4,v1,pt)>=0.0) {
+ if (line_point_side_v2(v1,v2,pt)>=0.0f) {
+ if (line_point_side_v2(v2,v3,pt)>=0.0f) {
+ if (line_point_side_v2(v3,v4,pt)>=0.0f) {
+ if (line_point_side_v2(v4,v1,pt)>=0.0f) {
return 1;
}
}
}
} else {
- if (! (line_point_side_v2(v2,v3,pt)>=0.0)) {
- if (! (line_point_side_v2(v3,v4,pt)>=0.0)) {
- if (! (line_point_side_v2(v4,v1,pt)>=0.0)) {
+ if (! (line_point_side_v2(v2,v3,pt)>=0.0f)) {
+ if (! (line_point_side_v2(v3,v4,pt)>=0.0f)) {
+ if (! (line_point_side_v2(v4,v1,pt)>=0.0f)) {
return -1;
}
}
@@ -446,7 +451,7 @@ int isect_point_quad_v2(float pt[2], float v1[2], float v2[2], float v3[2], floa
test if the line starting at p1 ending at p2 intersects the triangle v0..v2
return non zero if it does
*/
-int isect_line_tri_v3(float p1[3], float p2[3], float v0[3], float v1[3], float v2[3], float *lambda, float *uv)
+int isect_line_tri_v3(const float p1[3], const float p2[3], const float v0[3], const float v1[3], const float v2[3], float *lambda, float uv[2])
{
float p[3], s[3], d[3], e1[3], e2[3], q[3];
@@ -458,21 +463,21 @@ int isect_line_tri_v3(float p1[3], float p2[3], float v0[3], float v1[3], float
cross_v3_v3v3(p, d, e2);
a = dot_v3v3(e1, p);
- if ((a > -0.000001) && (a < 0.000001)) return 0;
+ if ((a > -0.000001f) && (a < 0.000001f)) return 0;
f = 1.0f/a;
sub_v3_v3v3(s, p1, v0);
u = f * dot_v3v3(s, p);
- if ((u < 0.0)||(u > 1.0)) return 0;
+ if ((u < 0.0f)||(u > 1.0f)) return 0;
cross_v3_v3v3(q, s, e1);
- v = f * dot_v3v3(d, q);
- if ((v < 0.0)||((u + v) > 1.0)) return 0;
+ v = f * dot_v3v3(d, q);
+ if ((v < 0.0f)||((u + v) > 1.0f)) return 0;
*lambda = f * dot_v3v3(e2, q);
- if ((*lambda < 0.0)||(*lambda > 1.0)) return 0;
+ if ((*lambda < 0.0f)||(*lambda > 1.0f)) return 0;
if(uv) {
uv[0]= u;
@@ -481,12 +486,11 @@ int isect_line_tri_v3(float p1[3], float p2[3], float v0[3], float v1[3], float
return 1;
}
-
/* moved from effect.c
test if the ray starting at p1 going in d direction intersects the triangle v0..v2
return non zero if it does
*/
-int isect_ray_tri_v3(float p1[3], float d[3], float v0[3], float v1[3], float v2[3], float *lambda, float *uv)
+int isect_ray_tri_v3(const float p1[3], const float d[3], const float v0[3], const float v1[3], const float v2[3], float *lambda, float uv[2])
{
float p[3], s[3], e1[3], e2[3], q[3];
float a, f, u, v;
@@ -498,23 +502,23 @@ int isect_ray_tri_v3(float p1[3], float d[3], float v0[3], float v1[3], float v2
a = dot_v3v3(e1, p);
/* note: these values were 0.000001 in 2.4x but for projection snapping on
* a human head (1BU==1m), subsurf level 2, this gave many errors - campbell */
- if ((a > -0.00000001) && (a < 0.00000001)) return 0;
+ if ((a > -0.00000001f) && (a < 0.00000001f)) return 0;
f = 1.0f/a;
sub_v3_v3v3(s, p1, v0);
u = f * dot_v3v3(s, p);
- if ((u < 0.0)||(u > 1.0)) return 0;
-
+ if ((u < 0.0f)||(u > 1.0f)) return 0;
+
cross_v3_v3v3(q, s, e1);
v = f * dot_v3v3(d, q);
- if ((v < 0.0)||((u + v) > 1.0)) return 0;
+ if ((v < 0.0f)||((u + v) > 1.0f)) return 0;
*lambda = f * dot_v3v3(e2, q);
- if ((*lambda < 0.0)) return 0;
+ if ((*lambda < 0.0f)) return 0;
- if(uv) {
+ if(uv) {
uv[0]= u;
uv[1]= v;
}
@@ -522,41 +526,71 @@ int isect_ray_tri_v3(float p1[3], float d[3], float v0[3], float v1[3], float v2
return 1;
}
-int isect_ray_tri_epsilon_v3(float p1[3], float d[3], float v0[3], float v1[3], float v2[3], float *lambda, float *uv, float epsilon)
+int isect_ray_plane_v3(float p1[3], float d[3], float v0[3], float v1[3], float v2[3], float *lambda, int clip)
{
- float p[3], s[3], e1[3], e2[3], q[3];
- float a, f, u, v;
+ float p[3], s[3], e1[3], e2[3], q[3];
+ float a, f;
+ /* float u, v; */ /*UNUSED*/
+
+ sub_v3_v3v3(e1, v1, v0);
+ sub_v3_v3v3(e2, v2, v0);
+
+ cross_v3_v3v3(p, d, e2);
+ a = dot_v3v3(e1, p);
+ /* note: these values were 0.000001 in 2.4x but for projection snapping on
+ * a human head (1BU==1m), subsurf level 2, this gave many errors - campbell */
+ if ((a > -0.00000001f) && (a < 0.00000001f)) return 0;
+ f = 1.0f/a;
+
+ sub_v3_v3v3(s, p1, v0);
+
+ /* u = f * dot_v3v3(s, p); */ /*UNUSED*/
+
+ cross_v3_v3v3(q, s, e1);
+
+ /* v = f * dot_v3v3(d, q); */ /*UNUSED*/
+
+ *lambda = f * dot_v3v3(e2, q);
+ if (clip && (*lambda < 0.0f)) return 0;
+
+ return 1;
+}
+
+int isect_ray_tri_epsilon_v3(const float p1[3], const float d[3], const float v0[3], const float v1[3], const float v2[3], float *lambda, float uv[2], const float epsilon)
+{
+ float p[3], s[3], e1[3], e2[3], q[3];
+ float a, f, u, v;
- sub_v3_v3v3(e1, v1, v0);
- sub_v3_v3v3(e2, v2, v0);
+ sub_v3_v3v3(e1, v1, v0);
+ sub_v3_v3v3(e2, v2, v0);
- cross_v3_v3v3(p, d, e2);
- a = dot_v3v3(e1, p);
- if (a == 0.0f) return 0;
- f = 1.0f/a;
+ cross_v3_v3v3(p, d, e2);
+ a = dot_v3v3(e1, p);
+ if (a == 0.0f) return 0;
+ f = 1.0f/a;
- sub_v3_v3v3(s, p1, v0);
+ sub_v3_v3v3(s, p1, v0);
- u = f * dot_v3v3(s, p);
- if ((u < -epsilon)||(u > 1.0f+epsilon)) return 0;
+ u = f * dot_v3v3(s, p);
+ if ((u < -epsilon)||(u > 1.0f+epsilon)) return 0;
- cross_v3_v3v3(q, s, e1);
+ cross_v3_v3v3(q, s, e1);
- v = f * dot_v3v3(d, q);
- if ((v < -epsilon)||((u + v) > 1.0f+epsilon)) return 0;
+ v = f * dot_v3v3(d, q);
+ if ((v < -epsilon)||((u + v) > 1.0f+epsilon)) return 0;
- *lambda = f * dot_v3v3(e2, q);
- if ((*lambda < 0.0f)) return 0;
+ *lambda = f * dot_v3v3(e2, q);
+ if ((*lambda < 0.0f)) return 0;
- if(uv) {
- uv[0]= u;
- uv[1]= v;
- }
+ if(uv) {
+ uv[0]= u;
+ uv[1]= v;
+ }
- return 1;
+ return 1;
}
-int isect_ray_tri_threshold_v3(float p1[3], float d[3], float v0[3], float v1[3], float v2[3], float *lambda, float *uv, float threshold)
+int isect_ray_tri_threshold_v3(const float p1[3], const float d[3], const float v0[3], const float v1[3], const float v2[3], float *lambda, float *uv, const float threshold)
{
float p[3], s[3], e1[3], e2[3], q[3];
float a, f, u, v;
@@ -567,14 +601,14 @@ int isect_ray_tri_threshold_v3(float p1[3], float d[3], float v0[3], float v1[3]
cross_v3_v3v3(p, d, e2);
a = dot_v3v3(e1, p);
- if ((a > -0.000001) && (a < 0.000001)) return 0;
+ if ((a > -0.000001f) && (a < 0.000001f)) return 0;
f = 1.0f/a;
sub_v3_v3v3(s, p1, v0);
cross_v3_v3v3(q, s, e1);
*lambda = f * dot_v3v3(e2, q);
- if ((*lambda < 0.0)) return 0;
+ if ((*lambda < 0.0f)) return 0;
u = f * dot_v3v3(s, p);
v = f * dot_v3v3(d, q);
@@ -609,7 +643,7 @@ int isect_ray_tri_threshold_v3(float p1[3], float d[3], float v0[3], float v1[3]
/* Adapted from the paper by Kasper Fauerby */
/* "Improved Collision detection and Response" */
-static int getLowestRoot(float a, float b, float c, float maxR, float* root)
+static int getLowestRoot(const float a, const float b, const float c, const float maxR, float *root)
{
// Check if a solution exists
float determinant = b*b - 4.0f*a*c;
@@ -646,7 +680,7 @@ static int getLowestRoot(float a, float b, float c, float maxR, float* root)
return 0;
}
-int isect_sweeping_sphere_tri_v3(float p1[3], float p2[3], float radius, float v0[3], float v1[3], float v2[3], float *lambda, float *ipoint)
+int isect_sweeping_sphere_tri_v3(const float p1[3], const float p2[3], const float radius, const float v0[3], const float v1[3], const float v2[3], float *lambda, float ipoint[3])
{
float e1[3], e2[3], e3[3], point[3], vel[3], /*dist[3],*/ nor[3], temp[3], bv[3];
float a, b, c, d, e, x, y, z, radius2=radius*radius;
@@ -668,10 +702,9 @@ int isect_sweeping_sphere_tri_v3(float p1[3], float p2[3], float radius, float v
a=dot_v3v3(p1,nor)-dot_v3v3(v0,nor);
nordotv=dot_v3v3(nor,vel);
- if (fabs(nordotv) < 0.000001)
+ if (fabsf(nordotv) < 0.000001f)
{
- if(fabs(a)>=radius)
- {
+ if(fabsf(a) >= radius) {
return 0;
}
}
@@ -844,7 +877,7 @@ int isect_sweeping_sphere_tri_v3(float p1[3], float p2[3], float radius, float v
return found_by_sweep;
}
-int isect_axial_line_tri_v3(int axis, float p1[3], float p2[3], float v0[3], float v1[3], float v2[3], float *lambda)
+int isect_axial_line_tri_v3(const int axis, const float p1[3], const float p2[3], const float v0[3], const float v1[3], const float v2[3], float *lambda)
{
float p[3], e1[3], e2[3];
float u, v, f;
@@ -865,25 +898,25 @@ int isect_axial_line_tri_v3(int axis, float p1[3], float p2[3], float v0[3], flo
sub_v3_v3v3(p,v0,p1);
f= (e2[a1]*e1[a2]-e2[a2]*e1[a1]);
- if ((f > -0.000001) && (f < 0.000001)) return 0;
+ if ((f > -0.000001f) && (f < 0.000001f)) return 0;
v= (p[a2]*e1[a1]-p[a1]*e1[a2])/f;
- if ((v < 0.0)||(v > 1.0)) return 0;
+ if ((v < 0.0f)||(v > 1.0f)) return 0;
f= e1[a1];
- if((f > -0.000001) && (f < 0.000001)){
+ if((f > -0.000001f) && (f < 0.000001f)){
f= e1[a2];
- if((f > -0.000001) && (f < 0.000001)) return 0;
+ if((f > -0.000001f) && (f < 0.000001f)) return 0;
u= (-p[a2]-v*e2[a2])/f;
}
else
u= (-p[a1]-v*e2[a1])/f;
- if ((u < 0.0)||((u + v) > 1.0)) return 0;
+ if ((u < 0.0f) || ((u + v) > 1.0f)) return 0;
*lambda = (p[a0]+u*e1[a0]+v*e2[a0])/(p2[a0]-p1[a0]);
- if ((*lambda < 0.0)||(*lambda > 1.0)) return 0;
+ if ((*lambda < 0.0f) || (*lambda > 1.0f)) return 0;
return 1;
}
@@ -893,7 +926,7 @@ int isect_axial_line_tri_v3(int axis, float p1[3], float p2[3], float v0[3], flo
* 1 - lines are coplanar, i1 is set to intersection
* 2 - i1 and i2 are the nearest points on line 1 (v1, v2) and line 2 (v3, v4) respectively
* */
-int isect_line_line_v3(float v1[3], float v2[3], float v3[3], float v4[3], float i1[3], float i2[3])
+int isect_line_line_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3], float i1[3], float i2[3])
{
float a[3], b[3], c[3], ab[3], cb[3], dir1[3], dir2[3];
float d;
@@ -957,7 +990,7 @@ int isect_line_line_v3(float v1[3], float v2[3], float v3[3], float v4[3], float
/* Intersection point strictly between the two lines
* 0 when no intersection is found
* */
-int isect_line_line_strict_v3(float v1[3], float v2[3], float v3[3], float v4[3], float vi[3], float *lambda)
+int isect_line_line_strict_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3], float vi[3], float *lambda)
{
float a[3], b[3], c[3], ab[3], cb[3], ca[3], dir1[3], dir2[3];
float d;
@@ -1010,7 +1043,7 @@ int isect_line_line_strict_v3(float v1[3], float v2[3], float v3[3], float v4[3]
}
}
-int isect_aabb_aabb_v3(float min1[3], float max1[3], float min2[3], float max2[3])
+int isect_aabb_aabb_v3(const float min1[3], const float max1[3], const float min2[3], const float max2[3])
{
return (min1[0]<max2[0] && min1[1]<max2[1] && min1[2]<max2[2] &&
min2[0]<max1[0] && min2[1]<max1[1] && min2[2]<max1[2]);
@@ -1054,7 +1087,7 @@ static float lambda_cp_line(float p[3], float l1[3], float l2[3])
#endif
/* Similar to LineIntersectsTriangleUV, except it operates on a quad and in 2d, assumes point is in quad */
-void isect_point_quad_uv_v2(float v0[2], float v1[2], float v2[2], float v3[2], float pt[2], float *uv)
+void isect_point_quad_uv_v2(const float v0[2], const float v1[2], const float v2[2], const float v3[2], const float pt[2], float *uv)
{
float x0,y0, x1,y1, wtot, v2d[2], w1, w2;
@@ -1148,7 +1181,7 @@ void isect_point_quad_uv_v2(float v0[2], float v1[2], float v2[2], float v3[2],
}
/* same as above but does tri's and quads, tri's are a bit of a hack */
-void isect_point_face_uv_v2(int isquad, float v0[2], float v1[2], float v2[2], float v3[2], float pt[2], float *uv)
+void isect_point_face_uv_v2(const int isquad, const float v0[2], const float v1[2], const float v2[2], const float v3[2], const float pt[2], float *uv)
{
if (isquad) {
isect_point_quad_uv_v2(v0, v1, v2, v3, pt, uv);
@@ -1234,7 +1267,7 @@ int isect_point_tri_v2(float v0[2], float v1[2], float v2[2], float pt[2])
x1,y1-- x2,y1
*/
-int isect_point_tri_v2_int(int x1, int y1, int x2, int y2, int a, int b)
+int isect_point_tri_v2_int(const int x1, const int y1, const int x2, const int y2, const int a, const int b)
{
float v1[2], v2[2], v3[2], p[2];
@@ -1253,7 +1286,7 @@ int isect_point_tri_v2_int(int x1, int y1, int x2, int y2, int a, int b)
return isect_point_tri_v2(p, v1, v2, v3);
}
-static int point_in_slice(float p[3], float v1[3], float l1[3], float l2[3])
+static int point_in_slice(const float p[3], const float v1[3], const float l1[3], const float l2[3])
{
/*
what is a slice ?
@@ -1301,7 +1334,7 @@ static int point_in_slice_m(float p[3],float origin[3],float normal[3],float lns
}
#endif
-int isect_point_tri_prism_v3(float p[3], float v1[3], float v2[3], float v3[3])
+int isect_point_tri_prism_v3(const float p[3], const float v1[3], const float v2[3], const float v3[3])
{
if(!point_in_slice(p,v1,v2,v3)) return 0;
if(!point_in_slice(p,v2,v3,v1)) return 0;
@@ -1309,7 +1342,7 @@ int isect_point_tri_prism_v3(float p[3], float v1[3], float v2[3], float v3[3])
return 1;
}
-int clip_line_plane(float p1[3], float p2[3], float plane[4])
+int clip_line_plane(float p1[3], float p2[3], const float plane[4])
{
float dp[3], n[3], div, t, pc[3];
@@ -1359,7 +1392,7 @@ int clip_line_plane(float p1[3], float p2[3], float plane[4])
}
-void plot_line_v2v2i(int p1[2], int p2[2], int (*callback)(int, int, void *), void *userData)
+void plot_line_v2v2i(const int p1[2], const int p2[2], int (*callback)(int, int, void *), void *userData)
{
int x1= p1[0];
int y1= p1[1];
@@ -1425,12 +1458,12 @@ void plot_line_v2v2i(int p1[2], int p2[2], int (*callback)(int, int, void *), vo
/****************************** Interpolation ********************************/
-static float tri_signed_area(float *v1, float *v2, float *v3, int i, int j)
+static float tri_signed_area(const float v1[3], const float v2[3], const float v3[3], const int i, const int j)
{
return 0.5f*((v1[i]-v2[i])*(v2[j]-v3[j]) + (v1[j]-v2[j])*(v3[i]-v2[i]));
}
-static int barycentric_weights(float *v1, float *v2, float *v3, float *co, float *n, float *w)
+static int barycentric_weights(const float v1[3], const float v2[3], const float v3[3], const float co[3], const float n[3], float w[3])
{
float xn, yn, zn, a1, a2, a3, asum;
short i, j;
@@ -1450,7 +1483,7 @@ static int barycentric_weights(float *v1, float *v2, float *v3, float *co, float
asum= a1 + a2 + a3;
- if (fabs(asum) < FLT_EPSILON) {
+ if (fabsf(asum) < FLT_EPSILON) {
/* zero area triangle */
w[0]= w[1]= w[2]= 1.0f/3.0f;
return 1;
@@ -1464,7 +1497,7 @@ static int barycentric_weights(float *v1, float *v2, float *v3, float *co, float
return 0;
}
-void interp_weights_face_v3(float *w,float *v1, float *v2, float *v3, float *v4, float *co)
+void interp_weights_face_v3(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];
@@ -1520,22 +1553,22 @@ void interp_weights_face_v3(float *w,float *v1, float *v2, float *v3, float *v4,
* note: using area_tri_signed_v2 means locations outside the triangle are correctly weighted */
void barycentric_weights_v2(const float v1[2], const float v2[2], const float v3[2], const float co[2], float w[3])
{
- float wtot_inv, wtot;
+ float wtot_inv, wtot;
- w[0] = area_tri_signed_v2(v2, v3, co);
- w[1] = area_tri_signed_v2(v3, v1, co);
- w[2] = area_tri_signed_v2(v1, v2, co);
- wtot = w[0]+w[1]+w[2];
+ w[0] = area_tri_signed_v2(v2, v3, co);
+ w[1] = area_tri_signed_v2(v3, v1, co);
+ w[2] = area_tri_signed_v2(v1, v2, co);
+ wtot = w[0]+w[1]+w[2];
- if (wtot != 0.0f) {
- wtot_inv = 1.0f/wtot;
+ if (wtot != 0.0f) {
+ wtot_inv = 1.0f/wtot;
- w[0] = w[0]*wtot_inv;
- w[1] = w[1]*wtot_inv;
- w[2] = w[2]*wtot_inv;
- }
- else /* dummy values for zero area face */
- w[0] = w[1] = w[2] = 1.0f/3.0f;
+ w[0] = w[0]*wtot_inv;
+ w[1] = w[1]*wtot_inv;
+ w[2] = w[2]*wtot_inv;
+ }
+ else /* dummy values for zero area face */
+ w[0] = w[1] = w[2] = 1.0f/3.0f;
}
/* given 2 triangles in 3D space, and a point in relation to the first triangle.
@@ -1588,7 +1621,7 @@ void barycentric_transform(float pt_tar[3], float const pt_src[3],
/* given an array with some invalid values this function interpolates valid values
* replacing the invalid ones */
-int interp_sparse_array(float *array, int list_size, float skipval)
+int interp_sparse_array(float *array, int const list_size, const float skipval)
{
int found_invalid = 0;
int found_valid = 0;
@@ -1668,7 +1701,7 @@ int interp_sparse_array(float *array, int list_size, float skipval)
/* Mean value weights - smooth interpolation weights for polygons with
* more than 3 vertices */
-static float mean_value_half_tan(float *v1, float *v2, float *v3)
+static float mean_value_half_tan(const float v1[3], const float v2[3], const float v3[3])
{
float d2[3], d3[3], cross[3], area, dot, len;
@@ -1686,7 +1719,7 @@ static float mean_value_half_tan(float *v1, float *v2, float *v3)
return (len - dot)/area;
}
-void interp_weights_poly_v3(float *w,float v[][3], int n, float *co)
+void interp_weights_poly_v3(float *w, float v[][3], const int n, const float co[3])
{
float totweight, t1, t2, len, *vmid, *vprev, *vnext;
int i;
@@ -1712,7 +1745,7 @@ void interp_weights_poly_v3(float *w,float v[][3], int n, float *co)
}
/* (x1,v1)(t1=0)------(x2,v2)(t2=1), 0<t<1 --> (x,v)(t) */
-void interp_cubic_v3(float *x, float *v,float *x1, float *v1, float *x2, float *v2, float t)
+void interp_cubic_v3(float x[3], float v[3], const float x1[3], const float v1[3], const float x2[3], const float v2[3], const float t)
{
float a[3],b[3];
float t2= t*t;
@@ -1738,14 +1771,14 @@ void interp_cubic_v3(float *x, float *v,float *x1, float *v1, float *x2, float *
/***************************** View & Projection *****************************/
-void orthographic_m4(float matrix[][4],float left, float right, float bottom, float top, float nearClip, float farClip)
+void orthographic_m4(float matrix[][4], const float left, const float right, const float bottom, const float top, const float nearClip, const float farClip)
{
float Xdelta, Ydelta, Zdelta;
Xdelta = right - left;
Ydelta = top - bottom;
Zdelta = farClip - nearClip;
- if (Xdelta == 0.0 || Ydelta == 0.0 || Zdelta == 0.0) {
+ if (Xdelta == 0.0f || Ydelta == 0.0f || Zdelta == 0.0f) {
return;
}
unit_m4(matrix);
@@ -1757,7 +1790,7 @@ void orthographic_m4(float matrix[][4],float left, float right, float bottom, fl
matrix[3][2] = -(farClip + nearClip)/Zdelta;
}
-void perspective_m4(float mat[][4],float left, float right, float bottom, float top, float nearClip, float farClip)
+void perspective_m4(float mat[4][4], const float left, const float right, const float bottom, const float top, const float nearClip, const float farClip)
{
float Xdelta, Ydelta, Zdelta;
@@ -1765,7 +1798,7 @@ void perspective_m4(float mat[][4],float left, float right, float bottom, float
Ydelta = top - bottom;
Zdelta = farClip - nearClip;
- if (Xdelta == 0.0 || Ydelta == 0.0 || Zdelta == 0.0) {
+ if (Xdelta == 0.0f || Ydelta == 0.0f || Zdelta == 0.0f) {
return;
}
mat[0][0] = nearClip * 2.0f/Xdelta;
@@ -1782,7 +1815,7 @@ void perspective_m4(float mat[][4],float left, float right, float bottom, float
}
/* translate a matrix created by orthographic_m4 or perspective_m4 in XY coords (used to jitter the view) */
-void window_translate_m4(float winmat[][4], float perspmat[][4], float x, float y)
+void window_translate_m4(float winmat[][4], float perspmat[][4], const float x, const float y)
{
if(winmat[2][3] == -1.0f) {
/* in the case of a win-matrix, this means perspective always */
@@ -1852,7 +1885,7 @@ void lookat_m4(float mat[][4],float vx, float vy, float vz, float px, float py,
hyp1 = (float)sqrt(dy*dy + hyp);
hyp = (float)sqrt(hyp); /* the real hyp */
- if (hyp1 != 0.0) { /* rotate X */
+ if (hyp1 != 0.0f) { /* rotate X */
sine = -dy / hyp1;
cosine = hyp /hyp1;
} else {
@@ -1886,7 +1919,7 @@ void lookat_m4(float mat[][4],float vx, float vy, float vz, float px, float py,
translate_m4(mat,-vx,-vy,-vz); /* translate viewpoint to origin */
}
-int box_clip_bounds_m4(float boundbox[2][3], float bounds[4], float winmat[4][4])
+int box_clip_bounds_m4(float boundbox[2][3], const float bounds[4], float winmat[4][4])
{
float mat[4][4], vec[4];
int a, fl, flag= -1;
@@ -1946,7 +1979,7 @@ void box_minmax_bounds_m4(float min[3], float max[3], float boundbox[2][3], floa
/********************************** Mapping **********************************/
-void map_to_tube(float *u, float *v,float x, float y, float z)
+void map_to_tube(float *u, float *v, const float x, const float y, const float z)
{
float len;
@@ -1959,22 +1992,64 @@ void map_to_tube(float *u, float *v,float x, float y, float z)
*v = *u = 0.0f; /* to avoid un-initialized variables */
}
-void map_to_sphere(float *u, float *v,float x, float y, float z)
+void map_to_sphere(float *u, float *v, const float x, const float y, const float z)
{
float len;
len= (float)sqrt(x*x+y*y+z*z);
if(len > 0.0f) {
if(x==0.0f && y==0.0f) *u= 0.0f; /* othwise domain error */
- else *u = (float)((1.0 - (float)atan2(x,y) / M_PI) / 2.0);
-
- z/=len;
- *v = 1.0f - (float)saacos(z)/(float)M_PI;
+ else *u = (1.0f - atan2f(x,y) / (float)M_PI) / 2.0f;
+
+ *v = 1.0f - (float)saacos(z/len)/(float)M_PI;
} else {
*v = *u = 0.0f; /* to avoid un-initialized variables */
}
}
+/********************************* Normals **********************************/
+
+void accumulate_vertex_normals(float n1[3], float n2[3], float n3[3],
+ float n4[3], const float f_no[3], const float co1[3], const float co2[3],
+ const float co3[3], const float co4[3])
+{
+ float vdiffs[4][3];
+ const int nverts= (n4!=NULL && co4!=NULL)? 4: 3;
+
+ /* compute normalized edge vectors */
+ sub_v3_v3v3(vdiffs[0], co2, co1);
+ sub_v3_v3v3(vdiffs[1], co3, co2);
+
+ if(nverts==3) {
+ sub_v3_v3v3(vdiffs[2], co1, co3);
+ }
+ else {
+ sub_v3_v3v3(vdiffs[2], co4, co3);
+ sub_v3_v3v3(vdiffs[3], co1, co4);
+ normalize_v3(vdiffs[3]);
+ }
+
+ normalize_v3(vdiffs[0]);
+ normalize_v3(vdiffs[1]);
+ normalize_v3(vdiffs[2]);
+
+ /* accumulate angle weighted face normal */
+ {
+ float *vn[]= {n1, n2, n3, n4};
+ const float *prev_edge = vdiffs[nverts-1];
+ int i;
+
+ for(i=0; i<nverts; i++) {
+ const float *cur_edge= vdiffs[i];
+ const float fac= saacos(-dot_v3v3(cur_edge, prev_edge));
+
+ // accumulate
+ madd_v3_v3fl(vn[i], f_no, fac);
+ prev_edge = cur_edge;
+ }
+ }
+}
+
/********************************* Tangents **********************************/
/* For normal map tangents we need to detect uv boundaries, and only average
@@ -1986,13 +2061,13 @@ void map_to_sphere(float *u, float *v,float x, float y, float z)
/* from BKE_mesh.h */
#define STD_UV_CONNECT_LIMIT 0.0001f
-void sum_or_add_vertex_tangent(void *arena, VertexTangent **vtang, float *tang, float *uv)
+void sum_or_add_vertex_tangent(void *arena, VertexTangent **vtang, const float tang[3], const float uv[2])
{
VertexTangent *vt;
/* find a tangent with connected uvs */
for(vt= *vtang; vt; vt=vt->next) {
- if(fabs(uv[0]-vt->uv[0]) < STD_UV_CONNECT_LIMIT && fabs(uv[1]-vt->uv[1]) < STD_UV_CONNECT_LIMIT) {
+ if(fabsf(uv[0]-vt->uv[0]) < STD_UV_CONNECT_LIMIT && fabsf(uv[1]-vt->uv[1]) < STD_UV_CONNECT_LIMIT) {
add_v3_v3(vt->tang, tang);
return;
}
@@ -2009,19 +2084,19 @@ void sum_or_add_vertex_tangent(void *arena, VertexTangent **vtang, float *tang,
*vtang= vt;
}
-float *find_vertex_tangent(VertexTangent *vtang, float *uv)
+float *find_vertex_tangent(VertexTangent *vtang, const float uv[2])
{
VertexTangent *vt;
static float nulltang[3] = {0.0f, 0.0f, 0.0f};
for(vt= vtang; vt; vt=vt->next)
- if(fabs(uv[0]-vt->uv[0]) < STD_UV_CONNECT_LIMIT && fabs(uv[1]-vt->uv[1]) < STD_UV_CONNECT_LIMIT)
+ if(fabsf(uv[0]-vt->uv[0]) < STD_UV_CONNECT_LIMIT && fabsf(uv[1]-vt->uv[1]) < STD_UV_CONNECT_LIMIT)
return vt->tang;
return nulltang; /* shouldn't happen, except for nan or so */
}
-void tangent_from_uv(float *uv1, float *uv2, float *uv3, float *co1, float *co2, float *co3, float *n, float *tang)
+void tangent_from_uv(float uv1[2], float uv2[2], float uv3[3], float co1[3], float co2[3], float co3[3], float n[3], float tang[3])
{
float s1= uv2[0] - uv1[0];
float s2= uv3[0] - uv1[0];
@@ -2080,7 +2155,7 @@ pointers may be NULL if not needed
*/
/* can't believe there is none in math utils */
-float _det_m3(float m2[3][3])
+static float _det_m3(float m2[3][3])
{
float det = 0.f;
if (m2){
@@ -2215,14 +2290,14 @@ void vcloud_estimate_transform(int list_size, float (*pos)[3], float *weight,flo
/******************************* Form Factor *********************************/
-static void vec_add_dir(float r[3], float v1[3], float v2[3], float fac)
+static void vec_add_dir(float r[3], const float v1[3], const float v2[3], const float fac)
{
r[0]= v1[0] + fac*(v2[0] - v1[0]);
r[1]= v1[1] + fac*(v2[1] - v1[1]);
r[2]= v1[2] + fac*(v2[2] - v1[2]);
}
-static int ff_visible_quad(float p[3], float n[3], float v0[3], float v1[3], float v2[3], float q0[3], float q1[3], float q2[3], float q3[3])
+static int ff_visible_quad(const float p[3], const float n[3], const float v0[3], const float v1[3], const float v2[3], float q0[3], float q1[3], float q2[3], float q3[3])
{
static const float epsilon = 1e-6f;
float c, sd[3];
@@ -2558,7 +2633,7 @@ static float ff_quad_form_factor(float *p, float *n, float *q0, float *q1, float
aresult = (_mm_set_ps1(n[0])*gx + _mm_set_ps1(n[1])*gy + _mm_set_ps1(n[2])*gz)*angle;
/* sum together */
- result= (fresult[0] + fresult[1] + fresult[2] + fresult[3])*(0.5f/(float)M_PI);
+ result= (fresult[0] + fresult[1] + fresult[2] + fresult[3])*(0.5f/(float)M_PI);
result= MAX2(result, 0.0f);
return result;
@@ -2581,7 +2656,7 @@ static void ff_normalize(float n[3])
}
}
-static float ff_quad_form_factor(float *p, float *n, float *q0, float *q1, float *q2, float *q3)
+static float ff_quad_form_factor(const float p[3], const float n[3], const float q0[3], const float q1[3], const float q2[3], const float q3[3])
{
float r0[3], r1[3], r2[3], r3[3], g0[3], g1[3], g2[3], g3[3];
float a1, a2, a3, a4, dot1, dot2, dot3, dot4, result;
diff --git a/source/blender/blenlib/intern/math_geom_inline.c b/source/blender/blenlib/intern/math_geom_inline.c
index c583990fef7..41dce131c17 100644
--- a/source/blender/blenlib/intern/math_geom_inline.c
+++ b/source/blender/blenlib/intern/math_geom_inline.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -25,6 +25,11 @@
* ***** END GPL LICENSE BLOCK *****
* */
+/** \file blender/blenlib/intern/math_geom_inline.c
+ * \ingroup bli
+ */
+
+
#include "BLI_math.h"
#ifndef BLI_MATH_GEOM_INLINE_H
@@ -37,12 +42,12 @@ MINLINE void zero_sh(float r[9])
memset(r, 0, sizeof(float)*9);
}
-MINLINE void copy_sh_sh(float r[9], float a[9])
+MINLINE void copy_sh_sh(float r[9], const float a[9])
{
memcpy(r, a, sizeof(float)*9);
}
-MINLINE void mul_sh_fl(float r[9], float f)
+MINLINE void mul_sh_fl(float r[9], const float f)
{
int i;
@@ -50,7 +55,7 @@ MINLINE void mul_sh_fl(float r[9], float f)
r[i] *= f;
}
-MINLINE void add_sh_shsh(float r[9], float a[9], float b[9])
+MINLINE void add_sh_shsh(float r[9], const float a[9], const float b[9])
{
int i;
@@ -69,7 +74,7 @@ MINLINE float dot_shsh(float a[9], float b[9])
return r;
}
-MINLINE float diffuse_shv3(float sh[9], float v[3])
+MINLINE float diffuse_shv3(float sh[9], const float v[3])
{
/* See formula (13) in:
"An Efficient Representation for Irradiance Environment Maps" */
@@ -91,7 +96,7 @@ MINLINE float diffuse_shv3(float sh[9], float v[3])
return sum;
}
-MINLINE void vec_fac_to_sh(float r[9], float v[3], float f)
+MINLINE void vec_fac_to_sh(float r[9], const float v[3], const float f)
{
/* See formula (3) in:
"An Efficient Representation for Irradiance Environment Maps" */
@@ -117,7 +122,7 @@ MINLINE void vec_fac_to_sh(float r[9], float v[3], float f)
copy_sh_sh(r, sh);
}
-MINLINE float eval_shv3(float sh[9], float v[3])
+MINLINE float eval_shv3(float sh[9], const float v[3])
{
float tmp[9];
@@ -125,7 +130,7 @@ MINLINE float eval_shv3(float sh[9], float v[3])
return dot_shsh(tmp, sh);
}
-MINLINE void madd_sh_shfl(float r[9], float sh[3], float f)
+MINLINE void madd_sh_shfl(float r[9], const float sh[3], const float f)
{
float tmp[9];
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index 75134358c31..9fde87d734f 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -25,6 +25,11 @@
* ***** END GPL LICENSE BLOCK *****
*/
+/** \file blender/blenlib/intern/math_matrix.c
+ * \ingroup bli
+ */
+
+
#include <assert.h>
#include "BLI_math.h"
@@ -242,7 +247,7 @@ void mul_serie_m3(float answ[][3],
{
float temp[3][3];
- if(m1==0 || m2==0) return;
+ if(m1==NULL || m2==NULL) return;
mul_m3_m3m3(answ, m2, m1);
if(m3) {
@@ -275,7 +280,7 @@ void mul_serie_m4(float answ[][4], float m1[][4],
{
float temp[4][4];
- if(m1==0 || m2==0) return;
+ if(m1==NULL || m2==NULL) return;
mul_m4_m4m4(answ, m2, m1);
if(m3) {
@@ -530,7 +535,7 @@ int invert_m4_m4(float inverse[4][4], float mat[4][4])
max = fabs(tempmat[i][i]);
maxj = i;
for(j = i + 1; j < 4; j++) {
- if(fabs(tempmat[j][i]) > max) {
+ if(fabsf(tempmat[j][i]) > max) {
max = fabs(tempmat[j][i]);
maxj = j;
}
@@ -755,13 +760,13 @@ void orthogonalize_m4(float mat[][4], int axis)
int is_orthogonal_m3(float mat[][3])
{
- if (fabs(dot_v3v3(mat[0], mat[1])) > 1.5 * FLT_EPSILON)
+ if (fabsf(dot_v3v3(mat[0], mat[1])) > 1.5f * FLT_EPSILON)
return 0;
- if (fabs(dot_v3v3(mat[1], mat[2])) > 1.5 * FLT_EPSILON)
+ if (fabsf(dot_v3v3(mat[1], mat[2])) > 1.5f * FLT_EPSILON)
return 0;
- if (fabs(dot_v3v3(mat[0], mat[2])) > 1.5 * FLT_EPSILON)
+ if (fabsf(dot_v3v3(mat[0], mat[2])) > 1.5f * FLT_EPSILON)
return 0;
return 1;
@@ -769,13 +774,13 @@ int is_orthogonal_m3(float mat[][3])
int is_orthogonal_m4(float mat[][4])
{
- if (fabs(dot_v3v3(mat[0], mat[1])) > 1.5 * FLT_EPSILON)
+ if (fabsf(dot_v3v3(mat[0], mat[1])) > 1.5f * FLT_EPSILON)
return 0;
- if (fabs(dot_v3v3(mat[1], mat[2])) > 1.5 * FLT_EPSILON)
+ if (fabsf(dot_v3v3(mat[1], mat[2])) > 1.5f * FLT_EPSILON)
return 0;
- if (fabs(dot_v3v3(mat[0], mat[2])) > 1.5 * FLT_EPSILON)
+ if (fabsf(dot_v3v3(mat[0], mat[2])) > 1.5f * FLT_EPSILON)
return 0;
return 1;
@@ -801,11 +806,11 @@ void normalize_m4(float mat[][4])
float len;
len= normalize_v3(mat[0]);
- if(len!=0.0) mat[0][3]/= len;
+ if(len!=0.0f) mat[0][3]/= len;
len= normalize_v3(mat[1]);
- if(len!=0.0) mat[1][3]/= len;
+ if(len!=0.0f) mat[1][3]/= len;
len= normalize_v3(mat[2]);
- if(len!=0.0) mat[2][3]/= len;
+ if(len!=0.0f) mat[2][3]/= len;
}
void normalize_m4_m4(float rmat[][4], float mat[][4])
@@ -813,11 +818,11 @@ void normalize_m4_m4(float rmat[][4], float mat[][4])
float len;
len= normalize_v3_v3(rmat[0], mat[0]);
- if(len!=0.0) rmat[0][3]= mat[0][3] / len;
+ if(len!=0.0f) rmat[0][3]= mat[0][3] / len;
len= normalize_v3_v3(rmat[1], mat[1]);
- if(len!=0.0) rmat[1][3]= mat[1][3] / len;
+ if(len!=0.0f) rmat[1][3]= mat[1][3] / len;
len= normalize_v3_v3(rmat[2], mat[2]);
- if(len!=0.0) rmat[2][3]= mat[2][3] / len;;
+ if(len!=0.0f) rmat[2][3]= mat[2][3] / len;;
}
void adjoint_m3_m3(float m1[][3], float m[][3])
@@ -1708,5 +1713,5 @@ void pseudoinverse_m4_m4(float Ainv[4][4], float A[4][4], float epsilon)
transpose_m4(V);
- mul_serie_m4(Ainv, U, Wm, V, 0, 0, 0, 0, 0);
+ mul_serie_m4(Ainv, U, Wm, V, NULL, NULL, NULL, NULL, NULL);
}
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index 2038121e3f2..dfd715ccbf2 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -25,6 +25,11 @@
* ***** END GPL LICENSE BLOCK *****
* */
+/** \file blender/blenlib/intern/math_rotation.c
+ * \ingroup bli
+ */
+
+
#include <assert.h>
#include "BLI_math.h"
@@ -162,10 +167,10 @@ static void quat_to_mat3_no_error(float m[][3], const float q[4])
{
double q0, q1, q2, q3, qda,qdb,qdc,qaa,qab,qac,qbb,qbc,qcc;
- q0= M_SQRT2 * q[0];
- q1= M_SQRT2 * q[1];
- q2= M_SQRT2 * q[2];
- q3= M_SQRT2 * q[3];
+ q0= M_SQRT2 * (double)q[0];
+ q1= M_SQRT2 * (double)q[1];
+ q2= M_SQRT2 * (double)q[2];
+ q3= M_SQRT2 * (double)q[3];
qda= q0*q1;
qdb= q0*q2;
@@ -195,7 +200,7 @@ void quat_to_mat3(float m[][3], const float q[4])
{
#ifdef DEBUG
float f;
- if(!((f=dot_qtqt(q, q))==0.0 || (fabs(f-1.0) < QUAT_EPSILON))) {
+ if(!((f=dot_qtqt(q, q))==0.0f || (fabsf(f-1.0f) < (float)QUAT_EPSILON))) {
fprintf(stderr, "Warning! quat_to_mat3() called with non-normalized: size %.8f *** report a bug ***\n", f);
}
#endif
@@ -208,15 +213,15 @@ void quat_to_mat4(float m[][4], const float q[4])
double q0, q1, q2, q3, qda,qdb,qdc,qaa,qab,qac,qbb,qbc,qcc;
#ifdef DEBUG
- if(!((q0=dot_qtqt(q, q))==0.0 || (fabs(q0-1.0) < QUAT_EPSILON))) {
+ if(!((q0=dot_qtqt(q, q))==0.0f || (fabsf(q0-1.0f) < (float)QUAT_EPSILON))) {
fprintf(stderr, "Warning! quat_to_mat4() called with non-normalized: size %.8f *** report a bug ***\n", (float)q0);
}
#endif
- q0= M_SQRT2 * q[0];
- q1= M_SQRT2 * q[1];
- q2= M_SQRT2 * q[2];
- q3= M_SQRT2 * q[3];
+ q0= M_SQRT2 * (double)q[0];
+ q1= M_SQRT2 * (double)q[1];
+ q2= M_SQRT2 * (double)q[2];
+ q3= M_SQRT2 * (double)q[3];
qda= q0*q1;
qdb= q0*q2;
@@ -256,9 +261,9 @@ void mat3_to_quat(float *q, float wmat[][3])
copy_m3_m3(mat, wmat);
normalize_m3(mat); /* this is needed AND a NormalQuat in the end */
- tr= 0.25*(1.0+mat[0][0]+mat[1][1]+mat[2][2]);
+ tr= 0.25* (double)(1.0f+mat[0][0]+mat[1][1]+mat[2][2]);
- if(tr>FLT_EPSILON) {
+ if(tr>(double)FLT_EPSILON) {
s= sqrt(tr);
q[0]= (float)s;
s= 1.0/(4.0*s);
@@ -268,7 +273,7 @@ void mat3_to_quat(float *q, float wmat[][3])
}
else {
if(mat[0][0] > mat[1][1] && mat[0][0] > mat[2][2]) {
- s= 2.0*sqrtf(1.0 + mat[0][0] - mat[1][1] - mat[2][2]);
+ s= 2.0*sqrtf(1.0f + mat[0][0] - mat[1][1] - mat[2][2]);
q[1]= (float)(0.25*s);
s= 1.0/s;
@@ -277,7 +282,7 @@ void mat3_to_quat(float *q, float wmat[][3])
q[3]= (float)((mat[2][0] + mat[0][2])*s);
}
else if(mat[1][1] > mat[2][2]) {
- s= 2.0*sqrtf(1.0 + mat[1][1] - mat[0][0] - mat[2][2]);
+ s= 2.0*sqrtf(1.0f + mat[1][1] - mat[0][0] - mat[2][2]);
q[2]= (float)(0.25*s);
s= 1.0/s;
@@ -356,7 +361,7 @@ float normalize_qt(float *q)
float len;
len= (float)sqrt(dot_qtqt(q, q));
- if(len!=0.0) {
+ if(len!=0.0f) {
mul_qt_fl(q, 1.0f/len);
}
else {
@@ -423,7 +428,7 @@ void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag)
q[1]=q[2]=q[3]= 0.0;
len1= (float)sqrt(x2*x2+y2*y2+z2*z2);
- if(len1 == 0.0) return;
+ if(len1 == 0.0f) return;
/* nasty! I need a good routine for this...
* problem is a rotation of an Y axis to the negative Y-axis for example.
@@ -626,11 +631,11 @@ void tri_to_quat(float quat[4], const float v1[3], const float v2[3], const floa
q2[1]= 0.0f;
q2[2]= 0.0f;
q2[3]= si;
-
+
mul_qt_qtqt(quat, q1, q2);
}
-void print_qt(char *str, float q[4])
+void print_qt(const char *str, const float q[4])
{
printf("%s: %.3f %.3f %.3f %.3f\n", str, q[0], q[1], q[2], q[3]);
}
@@ -662,7 +667,7 @@ void quat_to_axis_angle(float axis[3], float *angle, const float q[4])
float ha, si;
#ifdef DEBUG
- if(!((ha=dot_qtqt(q, q))==0.0 || (fabs(ha-1.0) < QUAT_EPSILON))) {
+ if(!((ha=dot_qtqt(q, q))==0.0f || (fabsf(ha-1.0f) < (float)QUAT_EPSILON))) {
fprintf(stderr, "Warning! quat_to_axis_angle() called with non-normalized: size %.8f *** report a bug ***\n", ha);
}
#endif
@@ -841,8 +846,8 @@ void vec_rot_to_quat(float *quat, const float vec[3], const float phi)
unit_qt(quat);
}
else {
- quat[0]= (float)cos(phi/2.0);
- si= (float)sin(phi/2.0);
+ quat[0]= (float)cos((double)phi/2.0);
+ si= (float)sin((double)phi/2.0);
quat[1] *= si;
quat[2] *= si;
quat[3] *= si;
@@ -923,7 +928,7 @@ static void mat3_to_eul2(float tmat[][3], float eul1[3], float eul2[3])
cy = (float)sqrt(mat[0][0]*mat[0][0] + mat[0][1]*mat[0][1]);
- if (cy > 16.0*FLT_EPSILON) {
+ if (cy > 16.0f*FLT_EPSILON) {
eul1[0] = (float)atan2(mat[1][2], mat[2][2]);
eul1[1] = (float)atan2(-mat[0][2], cy);
@@ -1040,13 +1045,13 @@ void compatible_eul(float eul[3], const float oldrot[3])
/* is 1 of the axis rotations larger than 180 degrees and the other small? NO ELSE IF!! */
if(fabs(dx) > 3.2 && fabs(dy)<1.6 && fabs(dz)<1.6) {
- if(dx > 0.0) eul[0] -= 2.0f*(float)M_PI; else eul[0]+= 2.0f*(float)M_PI;
+ if(dx > 0.0f) eul[0] -= 2.0f*(float)M_PI; else eul[0]+= 2.0f*(float)M_PI;
}
if(fabs(dy) > 3.2 && fabs(dz)<1.6 && fabs(dx)<1.6) {
- if(dy > 0.0) eul[1] -= 2.0f*(float)M_PI; else eul[1]+= 2.0f*(float)M_PI;
+ if(dy > 0.0f) eul[1] -= 2.0f*(float)M_PI; else eul[1]+= 2.0f*(float)M_PI;
}
if(fabs(dz) > 3.2 && fabs(dx)<1.6 && fabs(dy)<1.6) {
- if(dz > 0.0) eul[2] -= 2.0f*(float)M_PI; else eul[2]+= 2.0f*(float)M_PI;
+ if(dz > 0.0f) eul[2] -= 2.0f*(float)M_PI; else eul[2]+= 2.0f*(float)M_PI;
}
/* the method below was there from ancient days... but why! probably because the code sucks :)
@@ -1217,7 +1222,7 @@ static void mat3_to_eulo2(float M[3][3], float *e1, float *e2, short order)
cy= sqrt(m[i][i]*m[i][i] + m[i][j]*m[i][j]);
- if (cy > 16*FLT_EPSILON) {
+ if (cy > 16.0*(double)FLT_EPSILON) {
e1[i] = atan2(m[j][k], m[k][k]);
e1[j] = atan2(-m[i][k], cy);
e1[k] = atan2(m[i][j], m[i][i]);
@@ -1258,7 +1263,7 @@ void eulO_to_mat4(float M[4][4], const float e[3], const short order)
/* Convert 3x3 matrix to Euler angles (in radians). */
-void mat3_to_eulO(float eul[3], short order,float M[3][3])
+void mat3_to_eulO(float eul[3], const short order,float M[3][3])
{
float eul1[3], eul2[3];
@@ -1412,7 +1417,7 @@ void mat4_to_dquat(DualQuat *dq,float basemat[][4], float mat[][4])
copy_v3_v3(dscale, scale);
dscale[0] -= 1.0f; dscale[1] -= 1.0f; dscale[2] -= 1.0f;
- if((determinant_m4(mat) < 0.0f) || len_v3(dscale) > 1e-4) {
+ if((determinant_m4(mat) < 0.0f) || len_v3(dscale) > 1e-4f) {
/* extract R and S */
float tmp[4][4];
@@ -1431,7 +1436,7 @@ void mat4_to_dquat(DualQuat *dq,float basemat[][4], float mat[][4])
mul_m4_m4m4(S, baseRS, baseRinv);
/* set scaling part */
- mul_serie_m4(dq->scale, basemat, S, baseinv, 0, 0, 0, 0, 0);
+ mul_serie_m4(dq->scale, basemat, S, baseinv, NULL, NULL, NULL, NULL, NULL);
dq->scale_weight= 1.0f;
}
else {
@@ -1663,10 +1668,26 @@ void vec_apply_track(float vec[3], short axis)
/* lens/angle conversion (radians) */
float lens_to_angle(float lens)
{
- return 2.0f * atan(16.0f/lens);
+ return 2.0f * atanf(16.0f/lens);
}
float angle_to_lens(float angle)
{
- return 16.0f / tan(angle * 0.5f);
+ return 16.0f / tanf(angle * 0.5f);
+}
+
+/* 'mod_inline(-3,4)= 1', 'fmod(-3,4)= -3' */
+static float mod_inline(float a, float b)
+{
+ return a - (b * floorf(a / b));
+}
+
+float angle_wrap_rad(float angle)
+{
+ return mod_inline(angle + (float)M_PI, (float)M_PI*2.0f) - (float)M_PI;
+}
+
+float angle_wrap_deg(float angle)
+{
+ return mod_inline(angle + 180.0f, 360.0f) - 180.0f;
}
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index bcad7894e86..15d671e38d7 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -25,6 +25,11 @@
* ***** END GPL LICENSE BLOCK *****
* */
+/** \file blender/blenlib/intern/math_vector.c
+ * \ingroup bli
+ */
+
+
#include "BLI_math.h"
@@ -202,10 +207,10 @@ void angle_tri_v3(float angles[3], const float v1[3], const float v2[3], const f
normalize_v3(ed2);
normalize_v3(ed3);
- angles[0]= M_PI - angle_normalized_v3v3(ed1, ed2);
- angles[1]= M_PI - angle_normalized_v3v3(ed2, ed3);
+ angles[0]= (float)M_PI - angle_normalized_v3v3(ed1, ed2);
+ angles[1]= (float)M_PI - angle_normalized_v3v3(ed2, ed3);
// face_angles[2] = M_PI - angle_normalized_v3v3(ed3, ed1);
- angles[2]= M_PI - (angles[0] + angles[1]);
+ angles[2]= (float)M_PI - (angles[0] + angles[1]);
}
void angle_quad_v3(float angles[4], const float v1[3], const float v2[3], const float v3[3], const float v4[3])
@@ -222,10 +227,10 @@ void angle_quad_v3(float angles[4], const float v1[3], const float v2[3], const
normalize_v3(ed3);
normalize_v3(ed4);
- angles[0]= M_PI - angle_normalized_v3v3(ed1, ed2);
- angles[1]= M_PI - angle_normalized_v3v3(ed2, ed3);
- angles[2]= M_PI - angle_normalized_v3v3(ed3, ed4);
- angles[3]= M_PI - angle_normalized_v3v3(ed4, ed1);
+ angles[0]= (float)M_PI - angle_normalized_v3v3(ed1, ed2);
+ angles[1]= (float)M_PI - angle_normalized_v3v3(ed2, ed3);
+ angles[2]= (float)M_PI - angle_normalized_v3v3(ed3, ed4);
+ angles[3]= (float)M_PI - angle_normalized_v3v3(ed4, ed1);
}
/********************************* Geometry **********************************/
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index 2f808e5d74e..9f6a8afe2d5 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -25,6 +25,11 @@
* ***** END GPL LICENSE BLOCK *****
* */
+/** \file blender/blenlib/intern/math_vector_inline.c
+ * \ingroup bli
+ */
+
+
#include "BLI_math.h"
#ifndef BLI_MATH_VECTOR_INLINE_H
@@ -310,7 +315,7 @@ MINLINE float dot_v3v3(const float a[3], const float b[3])
MINLINE float cross_v2v2(const float a[2], const float b[2])
{
- return a[0]*b[1] - a[1]*b[0];
+ return a[0]*b[1] - a[1]*b[0];
}
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
@@ -419,14 +424,14 @@ MINLINE float normalize_v3(float n[3])
return normalize_v3_v3(n, n);
}
-MINLINE void normal_short_to_float_v3(float *out, const short *in)
+MINLINE void normal_short_to_float_v3(float out[3], const short in[3])
{
out[0] = in[0]*(1.0f/32767.0f);
out[1] = in[1]*(1.0f/32767.0f);
out[2] = in[2]*(1.0f/32767.0f);
}
-MINLINE void normal_float_to_short_v3(short *out, const float *in)
+MINLINE void normal_float_to_short_v3(short out[3], const float in[3])
{
out[0] = (short)(in[0]*32767.0f);
out[1] = (short)(in[1]*32767.0f);
@@ -467,9 +472,9 @@ MINLINE int equals_v4v4(const float *v1, const float *v2)
MINLINE int compare_v3v3(const float *v1, const float *v2, const float limit)
{
- if(fabs(v1[0]-v2[0])<limit)
- if(fabs(v1[1]-v2[1])<limit)
- if(fabs(v1[2]-v2[2])<limit)
+ if(fabsf(v1[0]-v2[0])<limit)
+ if(fabsf(v1[1]-v2[1])<limit)
+ if(fabsf(v1[2]-v2[2])<limit)
return 1;
return 0;
@@ -488,10 +493,10 @@ MINLINE int compare_len_v3v3(const float *v1, const float *v2, const float limit
MINLINE int compare_v4v4(const float *v1, const float *v2, const float limit)
{
- if(fabs(v1[0]-v2[0])<limit)
- if(fabs(v1[1]-v2[1])<limit)
- if(fabs(v1[2]-v2[2])<limit)
- if(fabs(v1[3]-v2[3])<limit)
+ if(fabsf(v1[0]-v2[0])<limit)
+ if(fabsf(v1[1]-v2[1])<limit)
+ if(fabsf(v1[2]-v2[2])<limit)
+ if(fabsf(v1[3]-v2[3])<limit)
return 1;
return 0;
diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c
index 96dad590fee..5d80edebbef 100644
--- a/source/blender/blenlib/intern/noise.c
+++ b/source/blender/blenlib/intern/noise.c
@@ -29,6 +29,11 @@
*
*/
+/** \file blender/blenlib/intern/noise.c
+ * \ingroup bli
+ */
+
+
#ifdef _WIN32
#pragma warning (disable : 4244) // "conversion from double to float"
#pragma warning (disable : 4305) // "truncation from const double to float"
@@ -36,6 +41,8 @@
#include <math.h>
+#include "BLI_noise.h"
+
/* local */
static float noise3_perlin(float vec[3]);
//static float turbulence_perlin(float *point, float lofreq, float hifreq);
@@ -388,7 +395,7 @@ static char p[512+2]= {
0xA2,0xA0};
-float g[512+2][3]= {
+static float g[512+2][3]= {
{0.33783, 0.715698, -0.611206},
{-0.944031, -0.326599, -0.045624},
{-0.101074, -0.416443, -0.903503},
@@ -1091,7 +1098,7 @@ static float dist_Minkovsky4(float x, float y, float z, float e)
/* Minkovsky, general case, slow, maybe too slow to be useful */
static float dist_Minkovsky(float x, float y, float z, float e)
{
- return pow(pow(fabs(x), e) + pow(fabs(y), e) + pow(fabs(z), e), 1.0/e);
+ return pow(pow(fabs(x), e) + pow(fabs(y), e) + pow(fabs(z), e), 1.0/e);
}
@@ -1268,18 +1275,18 @@ static float voronoi_CrS(float x, float y, float z)
/* returns unsigned cellnoise */
static float cellNoiseU(float x, float y, float z)
{
- int xi = (int)(floor(x));
- int yi = (int)(floor(y));
- int zi = (int)(floor(z));
- unsigned int n = xi + yi*1301 + zi*314159;
- n ^= (n<<13);
- return ((float)(n*(n*n*15731 + 789221) + 1376312589) / 4294967296.0);
+ int xi = (int)(floor(x));
+ int yi = (int)(floor(y));
+ int zi = (int)(floor(z));
+ unsigned int n = xi + yi*1301 + zi*314159;
+ n ^= (n<<13);
+ return ((float)(n*(n*n*15731 + 789221) + 1376312589) / 4294967296.0);
}
/* idem, signed */
float cellNoise(float x, float y, float z)
{
- return (2.0*cellNoiseU(x, y, z)-1.0);
+ return (2.0*cellNoiseU(x, y, z)-1.0);
}
/* returns a vector/point/color in ca, using point hasharray directly */
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 5d68fbe6e92..1f4b0ffdd5c 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -29,6 +29,11 @@
* various string, file, list operations.
*/
+/** \file blender/blenlib/intern/path_util.c
+ * \ingroup bli
+ */
+
+
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
@@ -53,8 +58,10 @@
#if defined WIN32 && !defined _LIBC
# include "BLI_fnmatch.h" /* use fnmatch included in blenlib */
#else
-# define _GNU_SOURCE
-# include <fnmatch.h>
+# ifndef _GNU_SOURCE
+# define _GNU_SOURCE
+# endif
+# include <fnmatch.h>
#endif
#ifdef WIN32
@@ -71,7 +78,7 @@
#else /* non windows */
-#ifdef __linux__
+#ifdef WITH_BINRELOC
#include "binreloc.h"
#endif
@@ -83,7 +90,7 @@
extern char bprogname[];
static int add_win32_extension(char *name);
-static char *blender_version_decimal(void);
+static char *blender_version_decimal(const int ver);
/* implementation */
@@ -199,7 +206,7 @@ void BLI_newname(char *name, int add)
int BLI_uniquename_cb(int (*unique_check)(void *, const char *), void *arg, const char defname[], char delim, char *name, short name_len)
{
- if(name == '\0') {
+ if(name[0] == '\0') {
BLI_strncpy(name, defname, name_len);
}
@@ -289,14 +296,7 @@ void BLI_uniquename(ListBase *list, void *vlink, const char defname[], char deli
* If relbase is NULL then its ignored
*/
-void BLI_cleanup_dir(const char *relabase, char *dir)
-{
- BLI_cleanup_file(relabase, dir);
- BLI_add_slash(dir);
-
-}
-
-void BLI_cleanup_file(const char *relabase, char *dir)
+void BLI_cleanup_path(const char *relabase, char *dir)
{
short a;
char *start, *eind;
@@ -324,8 +324,8 @@ void BLI_cleanup_file(const char *relabase, char *dir)
/* Note, this should really be moved to the file selector,
* since this function is used in many areas */
if(strcmp(dir, ".")==0) { /* happens for example in FILE_MAIN */
- get_default_root(dir);
- return;
+ get_default_root(dir);
+ return;
}
while ( (start = strstr(dir, "\\..\\")) ) {
@@ -351,18 +351,11 @@ void BLI_cleanup_file(const char *relabase, char *dir)
eind = start + strlen("\\\\") - 1;
memmove( start, eind, strlen(eind)+1 );
}
-
- if((a = strlen(dir))){ /* remove the '\\' at the end */
- while(a>0 && dir[a-1] == '\\'){
- a--;
- dir[a] = 0;
- }
- }
#else
if(dir[0]=='.') { /* happens, for example in FILE_MAIN */
- dir[0]= '/';
- dir[1]= 0;
- return;
+ dir[0]= '/';
+ dir[1]= 0;
+ return;
}
/* support for odd paths: eg /../home/me --> /home/me
@@ -395,17 +388,21 @@ void BLI_cleanup_file(const char *relabase, char *dir)
eind = start + (2 - 1) /* strlen("//") - 1 */;
memmove( start, eind, strlen(eind)+1 );
}
-
- if( (a = strlen(dir)) ){ /* remove all '/' at the end */
- while(dir[a-1] == '/'){
- a--;
- dir[a] = 0;
- if (a<=0) break;
- }
- }
#endif
}
+void BLI_cleanup_dir(const char *relabase, char *dir)
+{
+ BLI_cleanup_path(relabase, dir);
+ BLI_add_slash(dir);
+
+}
+
+void BLI_cleanup_file(const char *relabase, char *dir)
+{
+ BLI_cleanup_path(relabase, dir);
+ BLI_del_slash(dir);
+}
void BLI_path_rel(char *file, const char *relfile)
{
@@ -446,8 +443,8 @@ void BLI_path_rel(char *file, const char *relfile)
BLI_char_switch(file, '\\', '/');
/* remove /./ which confuse the following slash counting... */
- BLI_cleanup_file(NULL, file);
- BLI_cleanup_file(NULL, temp);
+ BLI_cleanup_path(NULL, file);
+ BLI_cleanup_path(NULL, temp);
/* the last slash in the file indicates where the path part ends */
lslash = BLI_last_slash(temp);
@@ -459,7 +456,12 @@ void BLI_path_rel(char *file, const char *relfile)
char *p= temp;
char *q= file;
- while (*p == *q) {
+#ifdef WIN32
+ while (tolower(*p) == tolower(*q))
+#else
+ while (*p == *q)
+#endif
+ {
++p; ++q;
/* dont search beyond the end of the string
* in the rare case they match */
@@ -523,7 +525,7 @@ int BLI_parent_dir(char *path)
BLI_add_slash(tmp);
strcat(tmp, parent_dir);
BLI_cleanup_dir(NULL, tmp);
-
+
if (!BLI_testextensie(tmp, parent_dir)) {
BLI_strncpy(path, tmp, sizeof(tmp));
return 1;
@@ -590,19 +592,7 @@ int BLI_path_frame(char *path, int frame, int digits)
if (stringframe_chars(path, &ch_sta, &ch_end)) { /* warning, ch_end is the last # +1 */
char tmp[FILE_MAX];
-#if 0 // neat but breaks on non ascii strings.
- char format[64];
- sprintf(format, "%%.%ds%%.%dd%%s", ch_sta, ch_end-ch_sta); /* example result: "%.12s%.5d%s" */
- sprintf(tmp, format, path, frame, path+ch_end);
-#else
- char format[8];
- char *p;
- sprintf(format, "%%.%dd", ch_end-ch_sta); /* example result: "%.5d" */
- memcpy(tmp, path, sizeof(char) * ch_sta);
- p= tmp + ch_sta;
- p += sprintf(p, format, frame);
- memcpy(p, path + ch_end, strlen(path + ch_end));
-#endif
+ sprintf(tmp, "%.*s%.*d%s", ch_sta, path, ch_end-ch_sta, frame, path+ch_end);
strcpy(path, tmp);
return 1;
}
@@ -617,19 +607,9 @@ int BLI_path_frame_range(char *path, int sta, int end, int digits)
ensure_digits(path, digits);
if (stringframe_chars(path, &ch_sta, &ch_end)) { /* warning, ch_end is the last # +1 */
- char tmp[FILE_MAX], format[64];
-#if 0 // neat but breaks on non ascii strings.
- sprintf(format, "%%.%ds%%.%dd_%%.%dd%%s", ch_sta, ch_end-ch_sta, ch_end-ch_sta); /* example result: "%.12s%.5d-%.5d%s" */
- sprintf(tmp, format, path, sta, end, path+ch_end);
+ char tmp[FILE_MAX];
+ sprintf(tmp, "%.*s%.*d-%.*d%s", ch_sta, path, ch_end-ch_sta, sta, ch_end-ch_sta, end, path+ch_end);
strcpy(path, tmp);
-#else
- char *tmp_pt;
- BLI_snprintf(format, sizeof(format), "%%.%dd-%%.%dd%%s", digits, digits);
- memcpy(tmp, path, ch_sta * sizeof(char));
- tmp_pt = &tmp[ch_sta];
- tmp_pt += BLI_snprintf(tmp_pt, sizeof(tmp)-ch_sta, format, sta, end, &path[ch_end]);
- memcpy(path, tmp, (int)(tmp_pt - tmp) + 1);
-#endif
return 1;
}
return 0;
@@ -679,8 +659,9 @@ int BLI_path_abs(char *path, const char *basepath)
#endif
BLI_strncpy(base, basepath, sizeof(base));
-
- BLI_cleanup_file(NULL, base);
+
+ /* file component is ignored, so dont bother with the trailing slash */
+ BLI_cleanup_path(NULL, base);
/* push slashes into unix mode - strings entering this part are
potentially messed up: having both back- and forward slashes.
@@ -709,17 +690,9 @@ int BLI_path_abs(char *path, const char *basepath)
} else {
BLI_strncpy(path, tmp, FILE_MAX);
}
-
- if (path[0]!='\0') {
- if ( path[strlen(path)-1]=='/') {
- /* remove the '/' so we avoid BLI_cleanup_dir adding an extra \ in WIN32 */
- path[strlen(path)-1] = '\0';
- BLI_cleanup_dir(NULL, path);
- } else {
- BLI_cleanup_file(NULL, path);
- }
- }
-
+
+ BLI_cleanup_path(NULL, path);
+
#ifdef WIN32
/* skip first two chars, which in case of
absolute path will be drive:/blabla and
@@ -752,8 +725,8 @@ int BLI_path_cwd(char *path)
#endif
if (wasrelative==1) {
- char cwd[FILE_MAXDIR + FILE_MAXFILE];
- BLI_getwdN(cwd); /* incase the full path to the blend isnt used */
+ char cwd[FILE_MAXDIR + FILE_MAXFILE]= "";
+ BLI_getwdN(cwd, sizeof(cwd)); /* incase the full path to the blend isnt used */
if (cwd[0] == '\0') {
printf( "Could not get the current working directory - $PWD for an unknown reason.");
@@ -790,7 +763,7 @@ void BLI_splitdirstring(char *di, char *fi)
}
}
-void BLI_getlastdir(const char* dir, char *last, int maxlen)
+void BLI_getlastdir(const char* dir, char *last, const size_t maxlen)
{
const char *s = dir;
const char *lslash = NULL;
@@ -812,12 +785,12 @@ void BLI_getlastdir(const char* dir, char *last, int maxlen)
/* This is now only used to really get the user's default document folder */
/* On Windows I chose the 'Users/<MyUserName>/Documents' since it's used
as default location to save documents */
-char *BLI_getDefaultDocumentFolder(void) {
+const char *BLI_getDefaultDocumentFolder(void) {
#if !defined(WIN32)
return getenv("HOME");
#else /* Windows */
- char * ret;
+ const char * ret;
static char documentfolder[MAXPATHLEN];
HRESULT hResult;
@@ -850,10 +823,10 @@ char *BLI_getDefaultDocumentFolder(void) {
// #define PATH_DEBUG2
-static char *blender_version_decimal(void)
+static char *blender_version_decimal(const int ver)
{
static char version_str[5];
- sprintf(version_str, "%d.%02d", BLENDER_VERSION/100, BLENDER_VERSION%100);
+ sprintf(version_str, "%d.%02d", ver/100, ver%100);
return version_str;
}
@@ -861,11 +834,15 @@ static int test_path(char *targetpath, const char *path_base, const char *path_s
{
char tmppath[FILE_MAX];
- if(path_sep) BLI_join_dirfile(tmppath, path_base, path_sep);
+ if(path_sep) BLI_join_dirfile(tmppath, sizeof(tmppath), path_base, path_sep);
else BLI_strncpy(tmppath, path_base, sizeof(tmppath));
-
- BLI_make_file_string("/", targetpath, tmppath, folder_name);
-
+
+ /* rare cases folder_name is omitted (when looking for ~/.blender/2.xx dir only) */
+ if(folder_name)
+ BLI_make_file_string("/", targetpath, tmppath, folder_name);
+ else
+ BLI_strncpy(targetpath, tmppath, sizeof(tmppath));
+
if (BLI_is_dir(targetpath)) {
#ifdef PATH_DEBUG2
printf("\tpath found: %s\n", targetpath);
@@ -883,7 +860,7 @@ static int test_path(char *targetpath, const char *path_base, const char *path_s
static int test_env_path(char *path, const char *envvar)
{
- char *env = envvar?getenv(envvar):NULL;
+ const char *env = envvar?getenv(envvar):NULL;
if (!env) return 0;
if (BLI_is_dir(env)) {
@@ -895,7 +872,7 @@ static int test_env_path(char *path, const char *envvar)
}
}
-static int get_path_local(char *targetpath, const char *folder_name, const char *subfolder_name)
+static int get_path_local(char *targetpath, const char *folder_name, const char *subfolder_name, const int ver)
{
char bprogdir[FILE_MAX];
char relfolder[FILE_MAX];
@@ -903,24 +880,29 @@ static int get_path_local(char *targetpath, const char *folder_name, const char
#ifdef PATH_DEBUG2
printf("get_path_local...\n");
#endif
-
- if (subfolder_name) {
- BLI_join_dirfile(relfolder, folder_name, subfolder_name);
- } else {
- BLI_strncpy(relfolder, folder_name, FILE_MAX);
+
+ if(folder_name) {
+ if (subfolder_name) {
+ BLI_join_dirfile(relfolder, sizeof(relfolder), folder_name, subfolder_name);
+ } else {
+ BLI_strncpy(relfolder, folder_name, sizeof(relfolder));
+ }
+ }
+ else {
+ relfolder[0]= '\0';
}
/* use argv[0] (bprogname) to get the path to the executable */
BLI_split_dirfile(bprogname, bprogdir, NULL);
/* try EXECUTABLE_DIR/2.5x/folder_name - new default directory for local blender installed files */
- if(test_path(targetpath, bprogdir, blender_version_decimal(), relfolder))
+ if(test_path(targetpath, bprogdir, blender_version_decimal(ver), relfolder))
return 1;
return 0;
}
-static int get_path_user(char *targetpath, const char *folder_name, const char *subfolder_name, const char *envvar)
+static int get_path_user(char *targetpath, const char *folder_name, const char *subfolder_name, const char *envvar, const int ver)
{
char user_path[FILE_MAX];
const char *user_base_path;
@@ -938,7 +920,7 @@ static int get_path_user(char *targetpath, const char *folder_name, const char *
user_base_path = (const char *)GHOST_getUserDir();
if (user_base_path) {
- BLI_snprintf(user_path, FILE_MAX, BLENDER_USER_FORMAT, user_base_path, blender_version_decimal());
+ BLI_snprintf(user_path, FILE_MAX, BLENDER_USER_FORMAT, user_base_path, blender_version_decimal(ver));
}
if(!user_path[0])
@@ -957,7 +939,7 @@ static int get_path_user(char *targetpath, const char *folder_name, const char *
}
}
-static int get_path_system(char *targetpath, const char *folder_name, const char *subfolder_name, const char *envvar)
+static int get_path_system(char *targetpath, const char *folder_name, const char *subfolder_name, const char *envvar, const int ver)
{
char system_path[FILE_MAX];
const char *system_base_path;
@@ -972,16 +954,24 @@ static int get_path_system(char *targetpath, const char *folder_name, const char
/* use argv[0] (bprogname) to get the path to the executable */
BLI_split_dirfile(bprogname, bprogdir, NULL);
- if (subfolder_name) {
- BLI_join_dirfile(relfolder, folder_name, subfolder_name);
- } else {
- BLI_strncpy(relfolder, folder_name, FILE_MAX);
+ if(folder_name) {
+ if (subfolder_name) {
+ BLI_join_dirfile(relfolder, sizeof(relfolder), folder_name, subfolder_name);
+ } else {
+ BLI_strncpy(relfolder, folder_name, sizeof(relfolder));
+ }
+ }
+ else {
+ relfolder[0]= '\0';
}
/* try CWD/release/folder_name */
- if(test_path(targetpath, BLI_getwdN(cwd), "release", relfolder))
- return 1;
-
+ if(BLI_getwdN(cwd, sizeof(cwd))) {
+ if(test_path(targetpath, cwd, "release", relfolder)) {
+ return 1;
+ }
+ }
+
/* try EXECUTABLE_DIR/release/folder_name */
if(test_path(targetpath, bprogdir, "release", relfolder))
return 1;
@@ -1002,7 +992,7 @@ static int get_path_system(char *targetpath, const char *folder_name, const char
system_base_path = (const char *)GHOST_getSystemDir();
if (system_base_path) {
- BLI_snprintf(system_path, FILE_MAX, BLENDER_SYSTEM_FORMAT, system_base_path, blender_version_decimal());
+ BLI_snprintf(system_path, FILE_MAX, BLENDER_SYSTEM_FORMAT, system_base_path, blender_version_decimal(ver));
}
if(!system_path[0])
@@ -1025,70 +1015,71 @@ static int get_path_system(char *targetpath, const char *folder_name, const char
/* returns the path if found, NULL string if not */
char *BLI_get_folder(int folder_id, const char *subfolder)
{
+ const int ver= BLENDER_VERSION;
static char path[FILE_MAX] = "";
switch (folder_id) {
case BLENDER_DATAFILES: /* general case */
- if (get_path_local(path, "datafiles", subfolder)) break;
- if (get_path_user(path, "datafiles", subfolder, "BLENDER_USER_DATAFILES")) break;
- if (get_path_system(path, "datafiles", subfolder, "BLENDER_SYSTEM_DATAFILES")) break;
+ if (get_path_local(path, "datafiles", subfolder, ver)) break;
+ if (get_path_user(path, "datafiles", subfolder, "BLENDER_USER_DATAFILES", ver)) break;
+ if (get_path_system(path, "datafiles", subfolder, "BLENDER_SYSTEM_DATAFILES", ver)) break;
return NULL;
case BLENDER_USER_DATAFILES:
- if (get_path_local(path, "datafiles", subfolder)) break;
- if (get_path_user(path, "datafiles", subfolder, "BLENDER_USER_DATAFILES")) break;
+ if (get_path_local(path, "datafiles", subfolder, ver)) break;
+ if (get_path_user(path, "datafiles", subfolder, "BLENDER_USER_DATAFILES", ver)) break;
return NULL;
case BLENDER_SYSTEM_DATAFILES:
- if (get_path_local(path, "datafiles", subfolder)) break;
- if (get_path_system(path, "datafiles", subfolder, "BLENDER_SYSTEM_DATAFILES")) break;
+ if (get_path_local(path, "datafiles", subfolder, ver)) break;
+ if (get_path_system(path, "datafiles", subfolder, "BLENDER_SYSTEM_DATAFILES", ver)) break;
return NULL;
case BLENDER_USER_AUTOSAVE:
- if (get_path_local(path, "autosave", subfolder)) break;
- if (get_path_user(path, "autosave", subfolder, "BLENDER_USER_DATAFILES")) break;
+ if (get_path_local(path, "autosave", subfolder, ver)) break;
+ if (get_path_user(path, "autosave", subfolder, "BLENDER_USER_DATAFILES", ver)) break;
return NULL;
case BLENDER_CONFIG: /* general case */
- if (get_path_local(path, "config", subfolder)) break;
- if (get_path_user(path, "config", subfolder, "BLENDER_USER_CONFIG")) break;
- if (get_path_system(path, "config", subfolder, "BLENDER_SYSTEM_CONFIG")) break;
+ if (get_path_local(path, "config", subfolder, ver)) break;
+ if (get_path_user(path, "config", subfolder, "BLENDER_USER_CONFIG", ver)) break;
+ if (get_path_system(path, "config", subfolder, "BLENDER_SYSTEM_CONFIG", ver)) break;
return NULL;
case BLENDER_USER_CONFIG:
- if (get_path_local(path, "config", subfolder)) break;
- if (get_path_user(path, "config", subfolder, "BLENDER_USER_CONFIG")) break;
+ if (get_path_local(path, "config", subfolder, ver)) break;
+ if (get_path_user(path, "config", subfolder, "BLENDER_USER_CONFIG", ver)) break;
return NULL;
case BLENDER_SYSTEM_CONFIG:
- if (get_path_local(path, "config", subfolder)) break;
- if (get_path_system(path, "config", subfolder, "BLENDER_SYSTEM_CONFIG")) break;
+ if (get_path_local(path, "config", subfolder, ver)) break;
+ if (get_path_system(path, "config", subfolder, "BLENDER_SYSTEM_CONFIG", ver)) break;
return NULL;
case BLENDER_SCRIPTS: /* general case */
- if (get_path_local(path, "scripts", subfolder)) break;
- if (get_path_user(path, "scripts", subfolder, "BLENDER_USER_SCRIPTS")) break;
- if (get_path_system(path, "scripts", subfolder, "BLENDER_SYSTEM_SCRIPTS")) break;
+ if (get_path_local(path, "scripts", subfolder, ver)) break;
+ if (get_path_user(path, "scripts", subfolder, "BLENDER_USER_SCRIPTS", ver)) break;
+ if (get_path_system(path, "scripts", subfolder, "BLENDER_SYSTEM_SCRIPTS", ver)) break;
return NULL;
case BLENDER_USER_SCRIPTS:
- if (get_path_local(path, "scripts", subfolder)) break;
- if (get_path_user(path, "scripts", subfolder, "BLENDER_USER_SCRIPTS")) break;
+ if (get_path_local(path, "scripts", subfolder, ver)) break;
+ if (get_path_user(path, "scripts", subfolder, "BLENDER_USER_SCRIPTS", ver)) break;
return NULL;
case BLENDER_SYSTEM_SCRIPTS:
- if (get_path_local(path, "scripts", subfolder)) break;
- if (get_path_system(path, "scripts", subfolder, "BLENDER_SYSTEM_SCRIPTS")) break;
+ if (get_path_local(path, "scripts", subfolder, ver)) break;
+ if (get_path_system(path, "scripts", subfolder, "BLENDER_SYSTEM_SCRIPTS", ver)) break;
return NULL;
case BLENDER_PYTHON: /* general case */
- if (get_path_local(path, "python", subfolder)) break;
- if (get_path_system(path, "python", subfolder, "BLENDER_SYSTEM_PYTHON")) break;
+ if (get_path_local(path, "python", subfolder, ver)) break;
+ if (get_path_system(path, "python", subfolder, "BLENDER_SYSTEM_PYTHON", ver)) break;
return NULL;
case BLENDER_SYSTEM_PYTHON:
- if (get_path_local(path, "python", subfolder)) break;
- if (get_path_system(path, "python", subfolder, "BLENDER_SYSTEM_PYTHON")) break;
+ if (get_path_local(path, "python", subfolder, ver)) break;
+ if (get_path_system(path, "python", subfolder, "BLENDER_SYSTEM_PYTHON", ver)) break;
return NULL;
}
@@ -1097,20 +1088,21 @@ char *BLI_get_folder(int folder_id, const char *subfolder)
char *BLI_get_user_folder_notest(int folder_id, const char *subfolder)
{
+ const int ver= BLENDER_VERSION;
static char path[FILE_MAX] = "";
switch (folder_id) {
case BLENDER_USER_DATAFILES:
- get_path_user(path, "datafiles", subfolder, "BLENDER_USER_DATAFILES");
+ get_path_user(path, "datafiles", subfolder, "BLENDER_USER_DATAFILES", ver);
break;
case BLENDER_USER_CONFIG:
- get_path_user(path, "config", subfolder, "BLENDER_USER_CONFIG");
+ get_path_user(path, "config", subfolder, "BLENDER_USER_CONFIG", ver);
break;
case BLENDER_USER_AUTOSAVE:
- get_path_user(path, "autosave", subfolder, "BLENDER_USER_AUTOSAVE");
+ get_path_user(path, "autosave", subfolder, "BLENDER_USER_AUTOSAVE", ver);
break;
case BLENDER_USER_SCRIPTS:
- get_path_user(path, "scripts", subfolder, "BLENDER_USER_SCRIPTS");
+ get_path_user(path, "scripts", subfolder, "BLENDER_USER_SCRIPTS", ver);
break;
}
if ('\0' == path[0]) {
@@ -1137,6 +1129,32 @@ char *BLI_get_folder_create(int folder_id, const char *subfolder)
return path;
}
+char *BLI_get_folder_version(const int id, const int ver, const int do_check)
+{
+ static char path[FILE_MAX] = "";
+ int ok;
+ switch(id) {
+ case BLENDER_RESOURCE_PATH_USER:
+ ok= get_path_user(path, NULL, NULL, NULL, ver);
+ break;
+ case BLENDER_RESOURCE_PATH_LOCAL:
+ ok= get_path_local(path, NULL, NULL, ver);
+ break;
+ case BLENDER_RESOURCE_PATH_SYSTEM:
+ ok= get_path_system(path, NULL, NULL, NULL, ver);
+ break;
+ default:
+ path[0]= '\0'; /* incase do_check is false */
+ ok= FALSE;
+ BLI_assert(!"incorrect ID");
+ }
+
+ if((ok == FALSE) && do_check) {
+ return NULL;
+ }
+
+ return path;
+}
/* End new stuff */
/* ************************************************************* */
@@ -1181,7 +1199,7 @@ void BLI_setenv_if_new(const char *env, const char* val)
void BLI_clean(char *path)
{
- if(path==0) return;
+ if(path==NULL) return;
#ifdef WIN32
if(path && BLI_strnlen(path, 3) > 2) {
@@ -1194,7 +1212,7 @@ void BLI_clean(char *path)
void BLI_char_switch(char *string, char from, char to)
{
- if(string==0) return;
+ if(string==NULL) return;
while (*string != 0) {
if (*string == from) *string = to;
string++;
@@ -1377,13 +1395,16 @@ int BLI_testextensie_glob(const char *str, const char *ext_fnmatch)
}
-int BLI_replace_extension(char *path, int maxlen, const char *ext)
+int BLI_replace_extension(char *path, size_t maxlen, const char *ext)
{
- int a;
+ size_t a;
- for(a=strlen(path)-1; a>=0; a--)
- if(path[a] == '.' || path[a] == '/' || path[a] == '\\')
+ for(a=strlen(path); a>0; a--) {
+ if(path[a-1] == '.' || path[a-1] == '/' || path[a-1] == '\\') {
+ a--;
break;
+ }
+ }
if(path[a] != '.')
a= strlen(path);
@@ -1420,12 +1441,12 @@ void BLI_split_dirfile(const char *string, char *dir, char *file)
}
/* simple appending of filename to dir, does not check for valid path! */
-void BLI_join_dirfile(char *string, const char *dir, const char *file)
+void BLI_join_dirfile(char *string, const size_t maxlen, const char *dir, const char *file)
{
int sl_dir;
if(string != dir) /* compare pointers */
- BLI_strncpy(string, dir, FILE_MAX);
+ BLI_strncpy(string, dir, maxlen);
if (!file)
return;
@@ -1433,7 +1454,7 @@ void BLI_join_dirfile(char *string, const char *dir, const char *file)
sl_dir= BLI_add_slash(string);
if (sl_dir <FILE_MAX) {
- BLI_strncpy(string + sl_dir, file, FILE_MAX-sl_dir);
+ BLI_strncpy(string + sl_dir, file, maxlen - sl_dir);
}
}
@@ -1470,7 +1491,7 @@ char *BLI_path_basename(char *path)
that a user gets his images in one place. It'll also provide
consistent behaviour across exporters.
*/
-int BKE_rebase_path(char *abs, int abs_size, char *rel, int rel_size, const char *base_dir, const char *src_dir, const char *dest_dir)
+int BKE_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const char *base_dir, const char *src_dir, const char *dest_dir)
{
char path[FILE_MAX];
char dir[FILE_MAX];
@@ -1507,34 +1528,34 @@ int BKE_rebase_path(char *abs, int abs_size, char *rel, int rel_size, const char
if (!strncmp(path, blend_dir, len)) {
/* if image is _in_ current .blend file directory */
- if (!strcmp(dir, blend_dir)) {
- BLI_join_dirfile(dest_path, dest_dir, base);
+ if (BLI_path_cmp(dir, blend_dir) == 0) {
+ BLI_join_dirfile(dest_path, sizeof(dest_path), dest_dir, base);
}
/* "below" */
else {
/* rel = image_path_dir - blend_dir */
BLI_strncpy(rel_dir, dir + len, sizeof(rel_dir));
- BLI_join_dirfile(dest_path, dest_dir, rel_dir);
- BLI_join_dirfile(dest_path, dest_path, base);
+ BLI_join_dirfile(dest_path, sizeof(dest_path), dest_dir, rel_dir);
+ BLI_join_dirfile(dest_path, sizeof(dest_path), dest_path, base);
}
}
/* image is out of current directory */
else {
- BLI_join_dirfile(dest_path, dest_dir, base);
+ BLI_join_dirfile(dest_path, sizeof(dest_path), dest_dir, base);
}
if (abs)
- BLI_strncpy(abs, dest_path, abs_size);
+ BLI_strncpy(abs, dest_path, abs_len);
if (rel) {
- strncat(rel, rel_dir, rel_size);
- strncat(rel, base, rel_size);
+ strncat(rel, rel_dir, rel_len);
+ strncat(rel, base, rel_len);
}
/* return 2 if src=dest */
- if (!strcmp(path, dest_path)) {
+ if (BLI_path_cmp(path, dest_path) == 0) {
// if (G.f & G_DEBUG) printf("%s and %s are the same file\n", path, dest_path);
return 2;
}
@@ -1614,7 +1635,7 @@ static int add_win32_extension(char *name)
#ifdef _WIN32
char filename[FILE_MAXDIR+FILE_MAXFILE];
char ext[FILE_MAXDIR+FILE_MAXFILE];
- char *extensions = getenv("PATHEXT");
+ const char *extensions = getenv("PATHEXT");
if (extensions) {
char *temp;
do {
@@ -1645,54 +1666,58 @@ static int add_win32_extension(char *name)
return (retval);
}
-void BLI_where_am_i(char *fullname, const char *name)
+/* filename must be FILE_MAX length minimum */
+void BLI_where_am_i(char *fullname, const size_t maxlen, const char *name)
{
char filename[FILE_MAXDIR+FILE_MAXFILE];
- char *path = NULL, *temp;
-
+ const char *path = NULL, *temp;
+
#ifdef _WIN32
const char *separator = ";";
- char slash = '\\';
#else
const char *separator = ":";
- char slash = '/';
#endif
-#ifdef __linux__
+#ifdef WITH_BINRELOC
/* linux uses binreloc since argv[0] is not relyable, call br_init( NULL ) first */
path = br_find_exe( NULL );
if (path) {
- BLI_strncpy(fullname, path, FILE_MAXDIR+FILE_MAXFILE);
- free(path);
+ BLI_strncpy(fullname, path, maxlen);
+ free((void *)path);
return;
}
#endif
#ifdef _WIN32
- if(GetModuleFileName(0, fullname, FILE_MAXDIR+FILE_MAXFILE)) {
- GetShortPathName(fullname, fullname, FILE_MAXDIR+FILE_MAXFILE);
+ if(GetModuleFileName(0, fullname, maxlen)) {
+ GetShortPathName(fullname, fullname, maxlen);
+ if(!BLI_exists(fullname)) {
+ printf("path can't be found: \"%.*s\"\n", maxlen, fullname);
+ MessageBox(NULL, "path constains invalid characters or is too long (see console)", "Error", MB_OK);
+ }
return;
}
#endif
/* unix and non linux */
- if (name && fullname && strlen(name)) {
- strcpy(fullname, name);
+ if (name && name[0]) {
+ BLI_strncpy(fullname, name, maxlen);
if (name[0] == '.') {
- // relative path, prepend cwd
- BLI_getwdN(fullname);
-
+ char wdir[FILE_MAX]= "";
+ BLI_getwdN(wdir, sizeof(wdir)); /* backup cwd to restore after */
+
// not needed but avoids annoying /./ in name
- if(name && name[0]=='.' && name[1]==slash)
- BLI_join_dirfile(fullname, fullname, name+2);
+ if(name[1]==SEP)
+ BLI_join_dirfile(fullname, maxlen, wdir, name+2);
else
- BLI_join_dirfile(fullname, fullname, name);
-
- add_win32_extension(fullname);
- } else if (BLI_last_slash(name)) {
+ BLI_join_dirfile(fullname, maxlen, wdir, name);
+
+ add_win32_extension(fullname); /* XXX, doesnt respect length */
+ }
+ else if (BLI_last_slash(name)) {
// full path
- strcpy(fullname, name);
+ BLI_strncpy(fullname, name, maxlen);
add_win32_extension(fullname);
} else {
// search for binary in $PATH
@@ -1707,9 +1732,9 @@ void BLI_where_am_i(char *fullname, const char *name)
} else {
strncpy(filename, path, sizeof(filename));
}
- BLI_join_dirfile(fullname, fullname, name);
+ BLI_join_dirfile(fullname, maxlen, fullname, name);
if (add_win32_extension(filename)) {
- strcpy(fullname, filename);
+ BLI_strncpy(fullname, filename, maxlen);
break;
}
} while (temp);
@@ -1727,7 +1752,7 @@ void BLI_where_am_i(char *fullname, const char *name)
// spaces and double-quotes. There's another solution to this
// with spawnv(P_WAIT, bprogname, argv) instead of system() but
// that's even uglier
- GetShortPathName(fullname, fullname, FILE_MAXDIR+FILE_MAXFILE);
+ GetShortPathName(fullname, fullname, maxlen);
#if defined(DEBUG)
printf("Shortname = '%s'\n", fullname);
#endif
@@ -1735,67 +1760,49 @@ void BLI_where_am_i(char *fullname, const char *name)
}
}
-void BLI_where_is_temp(char *fullname, int usertemp)
+void BLI_where_is_temp(char *fullname, const size_t maxlen, int usertemp)
{
fullname[0] = '\0';
if (usertemp && BLI_is_dir(U.tempdir)) {
- strcpy(fullname, U.tempdir);
+ BLI_strncpy(fullname, U.tempdir, maxlen);
}
#ifdef WIN32
if (fullname[0] == '\0') {
- char *tmp = getenv("TEMP"); /* Windows */
+ const char *tmp = getenv("TEMP"); /* Windows */
if (tmp && BLI_is_dir(tmp)) {
- strcpy(fullname, tmp);
+ BLI_strncpy(fullname, tmp, maxlen);
}
}
#else
/* Other OS's - Try TMP and TMPDIR */
if (fullname[0] == '\0') {
- char *tmp = getenv("TMP");
+ const char *tmp = getenv("TMP");
if (tmp && BLI_is_dir(tmp)) {
- strcpy(fullname, tmp);
+ BLI_strncpy(fullname, tmp, maxlen);
}
}
if (fullname[0] == '\0') {
- char *tmp = getenv("TMPDIR");
+ const char *tmp = getenv("TMPDIR");
if (tmp && BLI_is_dir(tmp)) {
- strcpy(fullname, tmp);
+ BLI_strncpy(fullname, tmp, maxlen);
}
}
#endif
if (fullname[0] == '\0') {
- strcpy(fullname, "/tmp/");
+ BLI_strncpy(fullname, "/tmp/", maxlen);
} else {
/* add a trailing slash if needed */
BLI_add_slash(fullname);
#ifdef WIN32
- strcpy(U.tempdir, fullname); /* also set user pref to show %TEMP%. /tmp/ is just plain confusing for Windows users. */
-#endif
- }
-}
-
-char *get_install_dir(void) {
- char *tmpname = BLI_strdup(bprogname);
- char *cut;
-
-#ifdef __APPLE__
- cut = strstr(tmpname, ".app");
- if (cut) cut[0] = 0;
+ if(U.tempdir != fullname) {
+ BLI_strncpy(U.tempdir, fullname, maxlen); /* also set user pref to show %TEMP%. /tmp/ is just plain confusing for Windows users. */
+ }
#endif
-
- cut = BLI_last_slash(tmpname);
-
- if (cut) {
- cut[0] = 0;
- return tmpname;
- } else {
- MEM_freeN(tmpname);
- return NULL;
}
}
diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c
index 9be42f9f5fc..95a43a998d3 100644
--- a/source/blender/blenlib/intern/pbvh.c
+++ b/source/blender/blenlib/intern/pbvh.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -20,6 +20,11 @@
* ***** END GPL LICENSE BLOCK *****
*/
+/** \file blender/blenlib/intern/pbvh.c
+ * \ingroup bli
+ */
+
+
#include "DNA_meshdata_types.h"
@@ -44,25 +49,27 @@
/* Bitmap */
typedef char* BLI_bitmap;
-BLI_bitmap BLI_bitmap_new(int tot)
+static BLI_bitmap BLI_bitmap_new(int tot)
{
return MEM_callocN((tot >> 3) + 1, "BLI bitmap");
}
-int BLI_bitmap_get(BLI_bitmap b, int index)
+static int BLI_bitmap_get(BLI_bitmap b, int index)
{
return b[index >> 3] & (1 << (index & 7));
}
-void BLI_bitmap_set(BLI_bitmap b, int index)
+static void BLI_bitmap_set(BLI_bitmap b, int index)
{
b[index >> 3] |= (1 << (index & 7));
}
-void BLI_bitmap_clear(BLI_bitmap b, int index)
+#if 0 /* UNUSED */
+static void BLI_bitmap_clear(BLI_bitmap b, int index)
{
b[index >> 3] &= ~(1 << (index & 7));
}
+#endif
/* Axis-aligned bounding box */
typedef struct {
@@ -264,7 +271,7 @@ static int partition_indices(int *prim_indices, int lo, int hi, int axis,
}
}
-void check_partitioning(int *prim_indices, int lo, int hi, int axis,
+static void check_partitioning(int *prim_indices, int lo, int hi, int axis,
float mid, BBC *prim_bbc, int index_of_2nd_partition)
{
int i;
@@ -405,7 +412,7 @@ static void build_grids_leaf_node(PBVH *bvh, PBVHNode *node)
offset and start indicate a range in the array of primitive indices
*/
-void build_sub(PBVH *bvh, int node_index, BB *cb, BBC *prim_bbc,
+static void build_sub(PBVH *bvh, int node_index, BB *cb, BBC *prim_bbc,
int offset, int count)
{
int i, axis, end;
@@ -665,7 +672,7 @@ static PBVHNode *pbvh_iter_next(PBVHIter *iter)
parents, this order is necessary for e.g. computing bounding boxes */
while(iter->stacksize) {
- /* pop node */
+ /* pop node */
iter->stacksize--;
node= iter->stack[iter->stacksize].node;
@@ -702,30 +709,30 @@ static PBVHNode *pbvh_iter_next(PBVHIter *iter)
static PBVHNode *pbvh_iter_next_occluded(PBVHIter *iter)
{
- PBVHNode *node;
-
- while(iter->stacksize) {
- /* pop node */
- iter->stacksize--;
- node= iter->stack[iter->stacksize].node;
-
- /* on a mesh with no faces this can happen
- * can remove this check if we know meshes have at least 1 face */
- if(node==NULL) return NULL;
-
- if(iter->scb && !iter->scb(node, iter->search_data)) continue; /* don't traverse, outside of search zone */
-
- if(node->flag & PBVH_Leaf) {
- /* immediately hit leaf node */
- return node;
- }
- else {
- pbvh_stack_push(iter, iter->bvh->nodes+node->children_offset+1, 0);
- pbvh_stack_push(iter, iter->bvh->nodes+node->children_offset, 0);
- }
- }
-
- return NULL;
+ PBVHNode *node;
+
+ while(iter->stacksize) {
+ /* pop node */
+ iter->stacksize--;
+ node= iter->stack[iter->stacksize].node;
+
+ /* on a mesh with no faces this can happen
+ * can remove this check if we know meshes have at least 1 face */
+ if(node==NULL) return NULL;
+
+ if(iter->scb && !iter->scb(node, iter->search_data)) continue; /* don't traverse, outside of search zone */
+
+ if(node->flag & PBVH_Leaf) {
+ /* immediately hit leaf node */
+ return node;
+ }
+ else {
+ pbvh_stack_push(iter, iter->bvh->nodes+node->children_offset+1, 0);
+ pbvh_stack_push(iter, iter->bvh->nodes+node->children_offset, 0);
+ }
+ }
+
+ return NULL;
}
void BLI_pbvh_search_gather(PBVH *bvh,
@@ -786,62 +793,62 @@ void BLI_pbvh_search_callback(PBVH *bvh,
}
typedef struct node_tree {
- PBVHNode* data;
+ PBVHNode* data;
- struct node_tree* left;
- struct node_tree* right;
+ struct node_tree* left;
+ struct node_tree* right;
} node_tree;
static void node_tree_insert(node_tree* tree, node_tree* new_node)
{
- if (new_node->data->tmin < tree->data->tmin) {
- if (tree->left) {
- node_tree_insert(tree->left, new_node);
- }
- else {
- tree->left = new_node;
- }
- }
- else {
- if (tree->right) {
- node_tree_insert(tree->right, new_node);
- }
- else {
- tree->right = new_node;
- }
- }
+ if (new_node->data->tmin < tree->data->tmin) {
+ if (tree->left) {
+ node_tree_insert(tree->left, new_node);
+ }
+ else {
+ tree->left = new_node;
+ }
+ }
+ else {
+ if (tree->right) {
+ node_tree_insert(tree->right, new_node);
+ }
+ else {
+ tree->right = new_node;
+ }
+ }
}
static void traverse_tree(node_tree* tree, BLI_pbvh_HitOccludedCallback hcb, void* hit_data, float* tmin)
{
- if (tree->left) traverse_tree(tree->left, hcb, hit_data, tmin);
+ if (tree->left) traverse_tree(tree->left, hcb, hit_data, tmin);
- hcb(tree->data, hit_data, tmin);
+ hcb(tree->data, hit_data, tmin);
- if (tree->right) traverse_tree(tree->right, hcb, hit_data, tmin);
+ if (tree->right) traverse_tree(tree->right, hcb, hit_data, tmin);
}
static void free_tree(node_tree* tree)
{
- if (tree->left) {
- free_tree(tree->left);
- tree->left = 0;
- }
+ if (tree->left) {
+ free_tree(tree->left);
+ tree->left = 0;
+ }
- if (tree->right) {
- free_tree(tree->right);
- tree->right = 0;
- }
+ if (tree->right) {
+ free_tree(tree->right);
+ tree->right = 0;
+ }
- free(tree);
+ free(tree);
}
float BLI_pbvh_node_get_tmin(PBVHNode* node)
{
- return node->tmin;
+ return node->tmin;
}
-void BLI_pbvh_search_callback_occluded(PBVH *bvh,
+static void BLI_pbvh_search_callback_occluded(PBVH *bvh,
BLI_pbvh_SearchCallback scb, void *search_data,
BLI_pbvh_HitOccludedCallback hcb, void *hit_data)
{
@@ -1122,7 +1129,7 @@ void BLI_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***gridfaces, int *tot
GHash *map;
void *face, **faces;
unsigned i;
- int tot;
+ int tot;
map = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "pbvh_get_grid_updates gh");
@@ -1311,17 +1318,17 @@ static int ray_face_intersection(float ray_start[3], float ray_normal[3],
float *t0, float *t1, float *t2, float *t3,
float *fdist)
{
- float dist;
-
- if ((isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t1, t2, &dist, NULL, 0.1f) && dist < *fdist) ||
- (t3 && isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t2, t3, &dist, NULL, 0.1f) && dist < *fdist))
- {
- *fdist = dist;
- return 1;
- }
- else {
- return 0;
- }
+ float dist;
+
+ if ((isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t1, t2, &dist, NULL, 0.1f) && dist < *fdist) ||
+ (t3 && isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t2, t3, &dist, NULL, 0.1f) && dist < *fdist))
+ {
+ *fdist = dist;
+ return 1;
+ }
+ else {
+ return 0;
+ }
}
int BLI_pbvh_node_raycast(PBVH *bvh, PBVHNode *node, float (*origco)[3],
@@ -1475,6 +1482,13 @@ void BLI_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*face_nors)[3], int smo
}
}
+void BLI_pbvh_grids_update(PBVH *bvh, DMGridData **grids, DMGridAdjacency *gridadj, void **gridfaces)
+{
+ bvh->grids= grids;
+ bvh->gridadj= gridadj;
+ bvh->gridfaces= gridfaces;
+}
+
float (*BLI_pbvh_get_vertCos(PBVH *pbvh))[3]
{
int a;
diff --git a/source/blender/blenlib/intern/rand.c b/source/blender/blenlib/intern/rand.c
index 7c14cfd3426..d889c1b9bf2 100644
--- a/source/blender/blenlib/intern/rand.c
+++ b/source/blender/blenlib/intern/rand.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -27,6 +27,11 @@
* ***** END GPL LICENSE BLOCK *****
*/
+/** \file blender/blenlib/intern/rand.c
+ * \ingroup bli
+ */
+
+
#include <stdlib.h>
#include <string.h>
diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c
index aa424c1c2bb..cf65539bd68 100644
--- a/source/blender/blenlib/intern/rct.c
+++ b/source/blender/blenlib/intern/rct.c
@@ -35,10 +35,16 @@
*
*/
-#include "DNA_vec_types.h"
+/** \file blender/blenlib/intern/rct.c
+ * \ingroup bli
+ */
+
#include <stdio.h>
#include <math.h>
+#include "DNA_vec_types.h"
+#include "BLI_rect.h"
+
int BLI_rcti_is_empty(rcti * rect)
{
return ((rect->xmax<=rect->xmin) ||
@@ -235,10 +241,10 @@ void BLI_copy_rcti_rctf(rcti *tar, const rctf *src)
void print_rctf(const char *str, rctf *rect)
{
- printf("%s: xmin %.3f, xmax %.3f, ymin %.3f, ymax %.3f\n", str, rect->xmin, rect->xmax, rect->ymin, rect->ymax);
+ printf("%s: xmin %.3f, xmax %.3f, ymin %.3f, ymax %.3f (%.3fx%.3f)\n", str, rect->xmin, rect->xmax, rect->ymin, rect->xmax, rect->xmax - rect->xmin, rect->ymax - rect->ymin);
}
void print_rcti(const char *str, rcti *rect)
{
- printf("%s: xmin %d, xmax %d, ymin %d, ymax %d\n", str, rect->xmin, rect->xmax, rect->ymin, rect->ymax);
+ printf("%s: xmin %d, xmax %d, ymin %d, ymax %d (%dx%d)\n", str, rect->xmin, rect->xmax, rect->ymin, rect->ymax, rect->xmax - rect->xmin, rect->ymax - rect->ymin);
}
diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c
index 1978e7ed7d6..423b9b99569 100644
--- a/source/blender/blenlib/intern/scanfill.c
+++ b/source/blender/blenlib/intern/scanfill.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -28,12 +28,18 @@
* (uit traces) maart 95
*/
-#include "MEM_guardedalloc.h"
+/** \file blender/blenlib/intern/scanfill.c
+ * \ingroup bli
+ */
+#include "MEM_guardedalloc.h"
+
+#include "BLI_callbacks.h"
#include "BLI_editVert.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
+#include "BLI_scanfill.h"
/* callbacks for errors and interrupts and some goo */
static void (*BLI_localErrorCallBack)(const char*) = NULL;
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index e407df7e9a1..e9db148e992 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -29,6 +29,11 @@
* Some really low-level file thingies.
*/
+/** \file blender/blenlib/intern/storage.c
+ * \ingroup bli
+ */
+
+
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
@@ -71,10 +76,6 @@
#include <pwd.h>
#endif
-#if !defined(__FreeBSD__) && !defined(__APPLE__)
-#include <malloc.h>
-#endif
-
#ifdef WIN32
#include <io.h>
#include <direct.h>
@@ -89,6 +90,7 @@
#include "BLI_listbase.h"
#include "BLI_linklist.h"
+#include "BLI_storage.h"
#include "BLI_storage_types.h"
#include "BLI_string.h"
@@ -98,25 +100,19 @@
static int totnum,actnum;
static struct direntry *files;
-static struct ListBase dirbase_={
- 0,0};
+static struct ListBase dirbase_={NULL, NULL};
static struct ListBase *dirbase = &dirbase_;
-
-char *BLI_getwdN(char *dir)
+/* can return NULL when the size is not big enough */
+char *BLI_getwdN(char *dir, const int maxncpy)
{
- char *pwd;
-
- if (dir) {
- pwd = getenv("PWD");
- if (pwd){
- strcpy(dir, pwd);
- return(dir);
- }
- /* 160 is FILE_MAXDIR in filesel.c */
- return( getcwd(dir, 160) );
+ const char *pwd= getenv("PWD");
+ if (pwd){
+ BLI_strncpy(dir, pwd, maxncpy);
+ return dir;
}
- return(0);
+
+ return getcwd(dir, maxncpy);
}
@@ -403,7 +399,7 @@ unsigned int BLI_getdir(const char *dirname, struct direntry **filelist)
// filesel.c:freefilelist()
actnum = totnum = 0;
- files = 0;
+ files = NULL;
BLI_builddir(dirname,"");
BLI_adddirstrings();
@@ -477,7 +473,7 @@ int BLI_is_dir(const char *file) {
return S_ISDIR(BLI_exist(file));
}
-LinkNode *BLI_read_file_as_lines(char *name)
+LinkNode *BLI_read_file_as_lines(const char *name)
{
FILE *fp= fopen(name, "r");
LinkNode *lines= NULL;
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c
index 6afc34ba630..ee5bd17c901 100644
--- a/source/blender/blenlib/intern/string.c
+++ b/source/blender/blenlib/intern/string.c
@@ -32,6 +32,11 @@
*
*/
+/** \file blender/blenlib/intern/string.c
+ * \ingroup bli
+ */
+
+
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
@@ -42,7 +47,7 @@
#include "BLI_dynstr.h"
#include "BLI_string.h"
-char *BLI_strdupn(const char *str, int len) {
+char *BLI_strdupn(const char *str, const size_t len) {
char *n= MEM_mallocN(len+1, "strdup");
memcpy(n, str, len);
n[len]= '\0';
@@ -55,7 +60,7 @@ char *BLI_strdup(const char *str) {
char *BLI_strdupcat(const char *str1, const char *str2)
{
- int len;
+ size_t len;
char *n;
len= strlen(str1)+strlen(str2);
@@ -66,9 +71,9 @@ char *BLI_strdupcat(const char *str1, const char *str2)
return n;
}
-char *BLI_strncpy(char *dst, const char *src, int maxncpy) {
- int srclen= strlen(src);
- int cpylen= (srclen>(maxncpy-1))?(maxncpy-1):srclen;
+char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy) {
+ size_t srclen= strlen(src);
+ size_t cpylen= (srclen>(maxncpy-1))?(maxncpy-1):srclen;
memcpy(dst, src, cpylen);
dst[cpylen]= '\0';
@@ -76,9 +81,9 @@ char *BLI_strncpy(char *dst, const char *src, int maxncpy) {
return dst;
}
-int BLI_snprintf(char *buffer, size_t count, const char *format, ...)
+size_t BLI_snprintf(char *buffer, size_t count, const char *format, ...)
{
- int n;
+ size_t n;
va_list arg;
va_start(arg, format);
@@ -123,7 +128,7 @@ char *BLI_sprintfN(const char *format, ...)
*/
char *BLI_getQuotedStr (const char *str, const char *prefix)
{
- int prefixLen = strlen(prefix);
+ size_t prefixLen = strlen(prefix);
char *startMatch, *endMatch;
/* get the starting point (i.e. where prefix starts, and add prefixLen+1 to it to get be after the first " */
@@ -133,7 +138,7 @@ char *BLI_getQuotedStr (const char *str, const char *prefix)
endMatch= strchr(startMatch, '"'); // " NOTE: this comment here is just so that my text editor still shows the functions ok...
/* return the slice indicated */
- return BLI_strdupn(startMatch, (int)(endMatch-startMatch));
+ return BLI_strdupn(startMatch, (size_t)(endMatch-startMatch));
}
/* Replaces all occurances of oldText with newText in str, returning a new string that doesn't
@@ -144,7 +149,7 @@ char *BLI_getQuotedStr (const char *str, const char *prefix)
char *BLI_replacestr(char *str, const char *oldText, const char *newText)
{
DynStr *ds= NULL;
- int lenOld= strlen(oldText);
+ size_t lenOld= strlen(oldText);
char *match;
/* sanity checks */
@@ -258,10 +263,10 @@ int BLI_strcasecmp(const char *s1, const char *s2) {
return 0;
}
-int BLI_strncasecmp(const char *s1, const char *s2, int n) {
+int BLI_strncasecmp(const char *s1, const char *s2, size_t len) {
int i;
- for (i=0; i<n; i++) {
+ for (i=0; i<len; i++) {
char c1 = tolower(s1[i]);
char c2 = tolower(s2[i]);
@@ -376,64 +381,64 @@ static const char trailingBytesForUTF8[256] = {
int BLI_utf8_invalid_byte(const char *str, int length)
{
- const unsigned char *p, *pend = (unsigned char*)str + length;
- unsigned char c;
- int ab;
-
- for (p = (unsigned char*)str; p < pend; p++) {
- c = *p;
- if (c < 128)
- continue;
- if ((c & 0xc0) != 0xc0)
- goto utf8_error;
- ab = trailingBytesForUTF8[c];
- if (length < ab)
- goto utf8_error;
- length -= ab;
-
- p++;
- /* Check top bits in the second byte */
- if ((*p & 0xc0) != 0x80)
- goto utf8_error;
-
- /* Check for overlong sequences for each different length */
- switch (ab) {
- /* Check for xx00 000x */
- case 1:
- if ((c & 0x3e) == 0) goto utf8_error;
- continue; /* We know there aren't any more bytes to check */
-
- /* Check for 1110 0000, xx0x xxxx */
- case 2:
- if (c == 0xe0 && (*p & 0x20) == 0) goto utf8_error;
- break;
-
- /* Check for 1111 0000, xx00 xxxx */
- case 3:
- if (c == 0xf0 && (*p & 0x30) == 0) goto utf8_error;
- break;
-
- /* Check for 1111 1000, xx00 0xxx */
- case 4:
- if (c == 0xf8 && (*p & 0x38) == 0) goto utf8_error;
- break;
-
- /* Check for leading 0xfe or 0xff,
- and then for 1111 1100, xx00 00xx */
- case 5:
- if (c == 0xfe || c == 0xff ||
- (c == 0xfc && (*p & 0x3c) == 0)) goto utf8_error;
- break;
- }
-
- /* Check for valid bytes after the 2nd, if any; all must start 10 */
- while (--ab > 0) {
- if ((*(p+1) & 0xc0) != 0x80) goto utf8_error;
+ const unsigned char *p, *pend = (unsigned char*)str + length;
+ unsigned char c;
+ int ab;
+
+ for (p = (unsigned char*)str; p < pend; p++) {
+ c = *p;
+ if (c < 128)
+ continue;
+ if ((c & 0xc0) != 0xc0)
+ goto utf8_error;
+ ab = trailingBytesForUTF8[c];
+ if (length < ab)
+ goto utf8_error;
+ length -= ab;
+
+ p++;
+ /* Check top bits in the second byte */
+ if ((*p & 0xc0) != 0x80)
+ goto utf8_error;
+
+ /* Check for overlong sequences for each different length */
+ switch (ab) {
+ /* Check for xx00 000x */
+ case 1:
+ if ((c & 0x3e) == 0) goto utf8_error;
+ continue; /* We know there aren't any more bytes to check */
+
+ /* Check for 1110 0000, xx0x xxxx */
+ case 2:
+ if (c == 0xe0 && (*p & 0x20) == 0) goto utf8_error;
+ break;
+
+ /* Check for 1111 0000, xx00 xxxx */
+ case 3:
+ if (c == 0xf0 && (*p & 0x30) == 0) goto utf8_error;
+ break;
+
+ /* Check for 1111 1000, xx00 0xxx */
+ case 4:
+ if (c == 0xf8 && (*p & 0x38) == 0) goto utf8_error;
+ break;
+
+ /* Check for leading 0xfe or 0xff,
+ and then for 1111 1100, xx00 00xx */
+ case 5:
+ if (c == 0xfe || c == 0xff ||
+ (c == 0xfc && (*p & 0x3c) == 0)) goto utf8_error;
+ break;
+ }
+
+ /* Check for valid bytes after the 2nd, if any; all must start 10 */
+ while (--ab > 0) {
+ if ((*(p+1) & 0xc0) != 0x80) goto utf8_error;
p++; /* do this after so we get usable offset - campbell */
- }
- }
+ }
+ }
- return -1;
+ return -1;
utf8_error:
diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c
index eb2057220fe..7b59a7905aa 100644
--- a/source/blender/blenlib/intern/threads.c
+++ b/source/blender/blenlib/intern/threads.c
@@ -1,4 +1,4 @@
-/**
+/*
*
* $Id$
*
@@ -28,6 +28,11 @@
* ***** END GPL LICENSE BLOCK *****
*/
+/** \file blender/blenlib/intern/threads.c
+ * \ingroup bli
+ */
+
+
#include <errno.h>
#include <string.h>
@@ -520,7 +525,7 @@ struct ThreadQueue {
int nowait;
};
-ThreadQueue *BLI_thread_queue_init()
+ThreadQueue *BLI_thread_queue_init(void)
{
ThreadQueue *queue;
diff --git a/source/blender/blenlib/intern/time.c b/source/blender/blenlib/intern/time.c
index 0992e08b28f..5bc7ca3609c 100644
--- a/source/blender/blenlib/intern/time.c
+++ b/source/blender/blenlib/intern/time.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -27,8 +27,14 @@
* ***** END GPL LICENSE BLOCK *****
*/
-#ifdef WIN32
+/** \file blender/blenlib/intern/time.c
+ * \ingroup bli
+ */
+
+
#include "PIL_time.h"
+
+#ifdef WIN32
#include <windows.h>
double PIL_check_seconds_timer(void)
diff --git a/source/blender/blenlib/intern/uvproject.c b/source/blender/blenlib/intern/uvproject.c
index b08f05b4fc8..d139fb1ab71 100644
--- a/source/blender/blenlib/intern/uvproject.c
+++ b/source/blender/blenlib/intern/uvproject.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -20,6 +20,11 @@
* ***** END GPL LICENSE BLOCK *****
*/
+/** \file blender/blenlib/intern/uvproject.c
+ * \ingroup bli
+ */
+
+
#include <math.h>
#include "MEM_guardedalloc.h"
@@ -28,6 +33,7 @@
#include "DNA_object_types.h"
#include "BLI_math.h"
+#include "BLI_uvproject.h"
typedef struct UvCameraInfo {
float camangle;
@@ -54,7 +60,7 @@ void project_from_camera(float target[2], float source[3], UvCameraInfo *uci)
mul_m4_v4(uci->caminv, pv4);
if(uci->do_pano) {
- float angle= atan2f(pv4[0], -pv4[2]) / (M_PI * 2.0); /* angle around the camera */
+ float angle= atan2f(pv4[0], -pv4[2]) / ((float)M_PI * 2.0f); /* angle around the camera */
if (uci->do_persp==0) {
target[0]= angle; /* no correct method here, just map to 0-1 */
target[1]= pv4[1] / uci->camsize;
@@ -63,7 +69,7 @@ void project_from_camera(float target[2], float source[3], UvCameraInfo *uci)
float vec2d[2]; /* 2D position from the camera */
vec2d[0]= pv4[0];
vec2d[1]= pv4[2];
- target[0]= angle * (M_PI / uci->camangle);
+ target[0]= angle * ((float)M_PI / uci->camangle);
target[1]= pv4[1] / (len_v2(vec2d) * uci->camsize);
}
}
@@ -103,23 +109,23 @@ void project_from_view(float target[2], float source[3], float persmat[4][4], fl
/* almost project_short */
mul_m4_v4(persmat, pv4);
- if(fabs(pv4[3]) > 0.00001) { /* avoid division by zero */
- target[0] = winx/2.0 + (winx/2.0) * pv4[0] / pv4[3];
- target[1] = winy/2.0 + (winy/2.0) * pv4[1] / pv4[3];
+ if(fabsf(pv4[3]) > 0.00001f) { /* avoid division by zero */
+ target[0] = winx/2.0f + (winx/2.0f) * pv4[0] / pv4[3];
+ target[1] = winy/2.0f + (winy/2.0f) * pv4[1] / pv4[3];
}
else {
/* scaling is lost but give a valid result */
- target[0] = winx/2.0 + (winx/2.0) * pv4[0];
- target[1] = winy/2.0 + (winy/2.0) * pv4[1];
+ target[0] = winx/2.0f + (winx/2.0f) * pv4[0];
+ target[1] = winy/2.0f + (winy/2.0f) * pv4[1];
}
/* v3d->persmat seems to do this funky scaling */
if(winx > winy) {
- y= (winx - winy)/2.0;
+ y= (winx - winy)/2.0f;
winy = winx;
}
else {
- x= (winy - winx)/2.0;
+ x= (winy - winx)/2.0f;
winx = winy;
}
diff --git a/source/blender/blenlib/intern/voxel.c b/source/blender/blenlib/intern/voxel.c
index 72a9c7d98ec..d11386ff606 100644
--- a/source/blender/blenlib/intern/voxel.c
+++ b/source/blender/blenlib/intern/voxel.c
@@ -1,4 +1,4 @@
-/**
+/*
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
@@ -26,6 +26,11 @@
* ***** END GPL LICENSE BLOCK *****
*/
+/** \file blender/blenlib/intern/voxel.c
+ * \ingroup bli
+ */
+
+
#include "BLI_voxel.h"
#include "BLI_utildefines.h"
diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c
index c7ec34d69a3..66080ed2a85 100644
--- a/source/blender/blenlib/intern/winstuff.c
+++ b/source/blender/blenlib/intern/winstuff.c
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -28,16 +28,23 @@
* Windows-posix compatibility layer, windows-specific functions.
*/
+/** \file blender/blenlib/intern/winstuff.c
+ * \ingroup bli
+ */
+
+
#ifdef WIN32
#include <stdlib.h>
#include <stdio.h>
+#include <conio.h>
#include "MEM_guardedalloc.h"
#include "BLI_path_util.h"
#include "BLI_string.h"
#include "BKE_utildefines.h"
+#include "BKE_global.h"
#define WIN32_SKIP_HKEY_PROTECTION // need to use HKEY
#include "BLI_winstuff.h"
@@ -59,39 +66,108 @@ int BLI_getInstallationDir( char * str ) {
return 1;
}
+void RegisterBlendExtension_Fail(HKEY root)
+{
+ printf("failed\n");
+ if (root)
+ RegCloseKey(root);
+ if (!G.background)
+ MessageBox(0,"Could not register file extension.","Blender error",MB_OK|MB_ICONERROR);
+ TerminateProcess(GetCurrentProcess(),1);
+}
-void RegisterBlendExtension(char * str) {
+void RegisterBlendExtension(void) {
LONG lresult;
HKEY hkey = 0;
+ HKEY root = 0;
+ BOOL usr_mode = FALSE;
DWORD dwd = 0;
- char buffer[128];
-
- lresult = RegCreateKeyEx(HKEY_CLASSES_ROOT, "blendfile\\shell\\open\\command", 0,
- "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
+ char buffer[256];
+
+ char BlPath[MAX_PATH];
+ char InstallDir[FILE_MAXDIR];
+ char SysDir[FILE_MAXDIR];
+ const char* ThumbHandlerDLL;
+ char RegCmd[MAX_PATH*2];
+ char MBox[256];
+ BOOL IsWOW64;
+
+ printf("Registering file extension...");
+ GetModuleFileName(0,BlPath,MAX_PATH);
+
+ // root is HKLM by default
+ lresult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Classes", 0, KEY_ALL_ACCESS, &root);
+ if (lresult != ERROR_SUCCESS)
+ {
+ // try HKCU on failure
+ usr_mode = TRUE;
+ lresult = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Classes", 0, KEY_ALL_ACCESS, &root);
+ if (lresult != ERROR_SUCCESS)
+ RegisterBlendExtension_Fail(0);
+ }
+ lresult = RegCreateKeyEx(root, "blendfile", 0,
+ NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
if (lresult == ERROR_SUCCESS) {
- sprintf(buffer, "\"%s\" \"%%1\"", str);
- lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, buffer, strlen(buffer) + 1);
+ sprintf(buffer,"%s","Blender File");
+ lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE*)buffer, strlen(buffer) + 1);
RegCloseKey(hkey);
}
+ if (lresult != ERROR_SUCCESS)
+ RegisterBlendExtension_Fail(root);
- lresult = RegCreateKeyEx(HKEY_CLASSES_ROOT, "blendfile\\DefaultIcon", 0,
- "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
-
+ lresult = RegCreateKeyEx(root, "blendfile\\shell\\open\\command", 0,
+ NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
if (lresult == ERROR_SUCCESS) {
- sprintf(buffer, "\"%s\",1", str);
- lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, buffer, strlen(buffer) + 1);
+ sprintf(buffer, "\"%s\" \"%%1\"", BlPath);
+ lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE*)buffer, strlen(buffer) + 1);
RegCloseKey(hkey);
}
+ if (lresult != ERROR_SUCCESS)
+ RegisterBlendExtension_Fail(root);
- lresult = RegCreateKeyEx(HKEY_CLASSES_ROOT, ".blend", 0,
- "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
+ lresult = RegCreateKeyEx(root, "blendfile\\DefaultIcon", 0,
+ NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
+ if (lresult == ERROR_SUCCESS) {
+ sprintf(buffer, "\"%s\",1", BlPath);
+ lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE*)buffer, strlen(buffer) + 1);
+ RegCloseKey(hkey);
+ }
+ if (lresult != ERROR_SUCCESS)
+ RegisterBlendExtension_Fail(root);
+ lresult = RegCreateKeyEx(root, ".blend", 0,
+ NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
if (lresult == ERROR_SUCCESS) {
sprintf(buffer, "%s", "blendfile");
- lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, buffer, strlen(buffer) + 1);
+ lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE*)buffer, strlen(buffer) + 1);
RegCloseKey(hkey);
}
+ if (lresult != ERROR_SUCCESS)
+ RegisterBlendExtension_Fail(root);
+
+ BLI_getInstallationDir(InstallDir);
+ GetSystemDirectory(SysDir,FILE_MAXDIR);
+#ifdef WIN64
+ ThumbHandlerDLL = "BlendThumb64.dll";
+#else
+ IsWow64Process(GetCurrentProcess(),&IsWOW64);
+ if (IsWOW64 == TRUE)
+ ThumbHandlerDLL = "BlendThumb64.dll";
+ else
+ ThumbHandlerDLL = "BlendThumb.dll";
+#endif
+ snprintf(RegCmd,MAX_PATH*2,"%s\\regsvr32 /s \"%s\\%s\"",SysDir,InstallDir,ThumbHandlerDLL);
+ system(RegCmd);
+
+ RegCloseKey(root);
+ printf("success (%s)\n",usr_mode ? "user" : "system");
+ if (!G.background)
+ {
+ sprintf(MBox,"File extension registered for %s.",usr_mode ? "the current user. To register for all users, run as an administrator" : "all users");
+ MessageBox(0,MBox,"Blender",MB_OK|MB_ICONINFORMATION);
+ }
+ TerminateProcess(GetCurrentProcess(),0);
}
DIR *opendir (const char *path) {
@@ -223,21 +299,21 @@ int check_file_chars(char *filename)
#include <string.h>
char* dirname(char *path)
{
- char *p;
- if( path == NULL || *path == '\0' )
- return ".";
- p = path + strlen(path) - 1;
- while( *p == '/' ) {
- if( p == path )
- return path;
- *p-- = '\0';
- }
- while( p >= path && *p != '/' )
- p--;
- return
- p < path ? "." :
- p == path ? "/" :
- (*p = '\0', path);
+ char *p;
+ if( path == NULL || *path == '\0' )
+ return ".";
+ p = path + strlen(path) - 1;
+ while( *p == '/' ) {
+ if( p == path )
+ return path;
+ *p-- = '\0';
+ }
+ while( p >= path && *p != '/' )
+ p--;
+ return
+ p < path ? "." :
+ p == path ? "/" :
+ (*p = '\0', path);
}
/* End of copied part */