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:
authorCampbell Barton <ideasman42@gmail.com>2009-12-29 18:40:26 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-12-29 18:40:26 +0300
commit5cd837a562d773cdff155ab05084af590341758d (patch)
tree20609a23f562cbf8ccf91b41af3f80240551b977 /source/blender/blenlib
parentd5cef9a30d1febb22b760eb7d5cdac0fd628bb06 (diff)
* speedup for animating bones, in one scene with sintel and a dragon animated its over 4x faster.
* utility function BLI_findstring to avoid listbase lookup loops everywhere. eg: ListBase *lb= objects= &CTX_data_main(C)->object; Object *ob= BLI_findstring(lb, name, offsetof(ID, name) + 2); * made some more math functions use const's, (fix warnings I made in previous commits)
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_listbase.h1
-rw-r--r--source/blender/blenlib/BLI_math_vector.h16
-rw-r--r--source/blender/blenlib/intern/listbase.c20
-rw-r--r--source/blender/blenlib/intern/math_vector_inline.c16
4 files changed, 37 insertions, 16 deletions
diff --git a/source/blender/blenlib/BLI_listbase.h b/source/blender/blenlib/BLI_listbase.h
index bd735888f95..f4841762227 100644
--- a/source/blender/blenlib/BLI_listbase.h
+++ b/source/blender/blenlib/BLI_listbase.h
@@ -44,6 +44,7 @@ void addlisttolist(struct ListBase *list1, struct ListBase *list2);
void BLI_insertlink(struct ListBase *listbase, void *vprevlink, void *vnewlink);
void *BLI_findlink(struct ListBase *listbase, int number);
int BLI_findindex(struct ListBase *listbase, void *vlink);
+void *BLI_findstring(struct ListBase *listbase, const char *id, 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_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 26e7ff5abe9..4dbef4ef07c 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -81,22 +81,22 @@ MINLINE void madd_v3_v3v3fl(float r[3], float a[3], float b[3], float f);
MINLINE void madd_v3_v3v3v3(float r[3], float a[3], float b[3], float c[3]);
MINLINE void negate_v3(float r[3]);
-MINLINE void negate_v3_v3(float r[3], float a[3]);
+MINLINE void negate_v3_v3(float r[3], const float a[3]);
-MINLINE float dot_v2v2(float a[2], float b[2]);
-MINLINE float dot_v3v3(float a[3], float b[3]);
+MINLINE float dot_v2v2(const float a[2], const float b[2]);
+MINLINE float dot_v3v3(const float a[3], const float b[3]);
-MINLINE float cross_v2v2(float a[2], float b[2]);
+MINLINE float cross_v2v2(const float a[2], const float b[2]);
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3]);
MINLINE void star_m3_v3(float R[3][3],float a[3]);
/*********************************** Length **********************************/
-MINLINE float len_v2(float a[2]);
-MINLINE float len_v2v2(float a[2], float b[2]);
-MINLINE float len_v3(float a[3]);
-MINLINE float len_v3v3(float a[3], float b[3]);
+MINLINE float len_v2(const float a[2]);
+MINLINE float len_v2v2(const float a[2], const float b[2]);
+MINLINE float len_v3(const float a[3]);
+MINLINE float len_v3v3(const float a[3], const float b[3]);
MINLINE float normalize_v2(float r[2]);
MINLINE float normalize_v3(float r[3]);
diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c
index 166f4ed029e..9b4e1720d8b 100644
--- a/source/blender/blenlib/intern/listbase.c
+++ b/source/blender/blenlib/intern/listbase.c
@@ -343,6 +343,26 @@ int BLI_findindex(ListBase *listbase, void *vlink)
return -1;
}
+void *BLI_findstring(ListBase *listbase, const char *id, int offset)
+{
+ Link *link= NULL;
+ const char *id_iter;
+
+ if (listbase == NULL) return NULL;
+
+ link= listbase->first;
+ while (link) {
+ id_iter= ((const char *)link) + offset;
+ printf("ASS '%s'\n", id_iter);
+ if(id[0] == id_iter[0] && strcmp(id, id_iter)==0)
+ return link;
+
+ link= link->next;
+ }
+
+ return NULL;
+}
+
void BLI_duplicatelist(ListBase *list1, const ListBase *list2)
{
struct Link *link1, *link2;
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index 16f35dbc5fa..8b09cb86d3a 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -194,24 +194,24 @@ MINLINE void negate_v3(float r[3])
r[2]= -r[2];
}
-MINLINE void negate_v3_v3(float r[3], float a[3])
+MINLINE void negate_v3_v3(float r[3], const float a[3])
{
r[0]= -a[0];
r[1]= -a[1];
r[2]= -a[2];
}
-MINLINE float dot_v2v2(float *a, float *b)
+MINLINE float dot_v2v2(const float a[2], const float b[2])
{
return a[0]*b[0] + a[1]*b[1];
}
-MINLINE float dot_v3v3(float a[3], float b[3])
+MINLINE float dot_v3v3(const float a[3], const float b[3])
{
return a[0]*b[0] + a[1]*b[1] + a[2]*b[2];
}
-MINLINE float cross_v2v2(float a[2], float b[2])
+MINLINE float cross_v2v2(const float a[2], const float b[2])
{
return a[0]*b[1] - a[1]*b[0];
}
@@ -236,12 +236,12 @@ MINLINE void star_m3_v3(float mat[][3], float *vec)
/*********************************** Length **********************************/
-MINLINE float len_v2(float *v)
+MINLINE float len_v2(const float v[2])
{
return (float)sqrt(v[0]*v[0] + v[1]*v[1]);
}
-MINLINE float len_v2v2(float *v1, float *v2)
+MINLINE float len_v2v2(const float v1[2], const float v2[2])
{
float x, y;
@@ -250,12 +250,12 @@ MINLINE float len_v2v2(float *v1, float *v2)
return (float)sqrt(x*x+y*y);
}
-MINLINE float len_v3(float a[3])
+MINLINE float len_v3(const float a[3])
{
return sqrtf(dot_v3v3(a, a));
}
-MINLINE float len_v3v3(float a[3], float b[3])
+MINLINE float len_v3v3(const float a[3], const float b[3])
{
float d[3];