[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21018] branches/blender2.5/blender/source : 2.5
Brecht Van Lommel
brecht at blender.org
Sat Jun 20 01:05:22 CEST 2009
Revision: 21018
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21018
Author: blendix
Date: 2009-06-20 01:05:21 +0200 (Sat, 20 Jun 2009)
Log Message:
-----------
2.5
* Optimized RNA property lookups and path resolving, still can be
much better, but now the 1000 IPO example on bf-taskforce25
runs at reasonable speed.
* Also an optimization in the depsgraph when dealing with many
objects, this was actually also a bottleneck here.
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/blenkernel/BKE_depsgraph.h
branches/blender2.5/blender/source/blender/blenkernel/depsgraph_private.h
branches/blender2.5/blender/source/blender/blenkernel/intern/depsgraph.c
branches/blender2.5/blender/source/blender/makesrna/RNA_define.h
branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c
branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c
branches/blender2.5/blender/source/blender/makesrna/intern/rna_define.c
branches/blender2.5/blender/source/blender/makesrna/intern/rna_internal.h
branches/blender2.5/blender/source/blender/makesrna/intern/rna_internal_types.h
branches/blender2.5/blender/source/blender/makesrna/intern/rna_rna.c
branches/blender2.5/blender/source/creator/creator.c
branches/blender2.5/blender/source/gameengine/GamePlayer/ghost/CMakeLists.txt
branches/blender2.5/blender/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
branches/blender2.5/blender/source/gameengine/GamePlayer/ghost/Makefile
branches/blender2.5/blender/source/gameengine/GamePlayer/ghost/SConscript
Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_depsgraph.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_depsgraph.h 2009-06-19 22:16:30 UTC (rev 21017)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_depsgraph.h 2009-06-19 23:05:21 UTC (rev 21018)
@@ -36,6 +36,7 @@
struct DagNodeQueue;
struct DagForest;
struct DagNode;
+struct GHash;
/* **** DAG relation types *** */
Modified: branches/blender2.5/blender/source/blender/blenkernel/depsgraph_private.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/depsgraph_private.h 2009-06-19 22:16:30 UTC (rev 21017)
+++ branches/blender2.5/blender/source/blender/blenkernel/depsgraph_private.h 2009-06-19 23:05:21 UTC (rev 21018)
@@ -65,6 +65,7 @@
void * first_ancestor;
int ancestor_count;
int lay; // accumulated layers of its relations + itself
+ int scelay; // layers due to being in scene
int lasttime; // if lasttime != DagForest->time, this node was not evaluated yet for flushing
int BFS_dist; // BFS distance
int DFS_dist; // DFS distance
@@ -93,6 +94,7 @@
typedef struct DagForest
{
ListBase DagNode;
+ struct GHash *nodeHash;
int numNodes;
int is_acyclic;
int time; // for flushing/tagging, compare with node->lasttime
Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/depsgraph.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/depsgraph.c 2009-06-19 22:16:30 UTC (rev 21017)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/depsgraph.c 2009-06-19 23:05:21 UTC (rev 21018)
@@ -61,6 +61,8 @@
#include "DNA_view2d_types.h"
#include "DNA_view3d_types.h"
+#include "BLI_ghash.h"
+
#include "BKE_action.h"
#include "BKE_effect.h"
#include "BKE_global.h"
@@ -754,6 +756,9 @@
itN = itN->next;
MEM_freeN(tempN);
}
+
+ BLI_ghash_free(Dag->nodeHash, NULL, NULL);
+ Dag->nodeHash= NULL;
Dag->DagNode.first = NULL;
Dag->DagNode.last = NULL;
Dag->numNodes = 0;
@@ -762,13 +767,9 @@
DagNode * dag_find_node (DagForest *forest,void * fob)
{
- DagNode *node = forest->DagNode.first;
-
- while (node) {
- if (node->ob == fob)
- return node;
- node = node->next;
- }
+ if(forest->nodeHash)
+ return BLI_ghash_lookup(forest->nodeHash, fob);
+
return NULL;
}
@@ -794,7 +795,12 @@
forest->DagNode.first = node;
forest->numNodes = 1;
}
+
+ if(!forest->nodeHash)
+ forest->nodeHash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
+ BLI_ghash_insert(forest->nodeHash, fob, node);
}
+
return node;
}
@@ -1805,17 +1811,10 @@
/* node was checked to have lasttime != curtime , and is of type ID_OB */
static unsigned int flush_layer_node(Scene *sce, DagNode *node, int curtime)
{
- Base *base;
DagAdjList *itA;
node->lasttime= curtime;
- node->lay= 0;
- for(base= sce->base.first; base; base= base->next) {
- if(node->ob == base->object) {
- node->lay= ((Object *)node->ob)->lay;
- break;
- }
- }
+ node->lay= node->scelay;
for(itA = node->child; itA; itA= itA->next) {
if(itA->node->type==ID_OB) {
@@ -1860,9 +1859,10 @@
/* flushes all recalc flags in objects down the dependency tree */
void DAG_scene_flush_update(Scene *sce, unsigned int lay, int time)
{
- DagNode *firstnode;
+ DagNode *firstnode, *node;
DagAdjList *itA;
Object *ob;
+ Base *base;
int lasttime;
if(sce->theDag==NULL) {
@@ -1879,6 +1879,15 @@
sce->theDag->time++; // so we know which nodes were accessed
lasttime= sce->theDag->time;
+
+ for(base= sce->base.first; base; base= base->next) {
+ node= dag_get_node(sce->theDag, base->object);
+ if(node)
+ node->scelay= base->object->lay;
+ else
+ node->scelay= 0;
+ }
+
for(itA = firstnode->child; itA; itA= itA->next)
if(itA->node->lasttime!=lasttime && itA->node->type==ID_OB)
flush_layer_node(sce, itA->node, lasttime);
Modified: branches/blender2.5/blender/source/blender/makesrna/RNA_define.h
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/RNA_define.h 2009-06-19 22:16:30 UTC (rev 21017)
+++ branches/blender2.5/blender/source/blender/makesrna/RNA_define.h 2009-06-19 23:05:21 UTC (rev 21018)
@@ -42,6 +42,8 @@
BlenderRNA *RNA_create(void);
void RNA_define_free(BlenderRNA *brna);
void RNA_free(BlenderRNA *brna);
+
+void RNA_init(void);
void RNA_exit(void);
/* Struct */
Modified: branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c 2009-06-19 22:16:30 UTC (rev 21017)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c 2009-06-19 23:05:21 UTC (rev 21018)
@@ -1488,8 +1488,8 @@
if(nest != NULL) {
len= strlen(nest);
- strnest= MEM_mallocN(sizeof(char)*(len+1), "rna_generate_property -> strnest");
- errnest= MEM_mallocN(sizeof(char)*(len+1), "rna_generate_property -> errnest");
+ strnest= MEM_mallocN(sizeof(char)*(len+2), "rna_generate_property -> strnest");
+ errnest= MEM_mallocN(sizeof(char)*(len+2), "rna_generate_property -> errnest");
strcpy(strnest, "_"); strcat(strnest, nest);
strcpy(errnest, "."); strcat(errnest, nest);
@@ -1713,6 +1713,8 @@
if(func->cont.prev) fprintf(f, "(FunctionRNA*)&rna_%s_%s_func,\n", srna->identifier, ((FunctionRNA*)func->cont.prev)->identifier);
else fprintf(f, "NULL,\n");
+ fprintf(f, "\tNULL,\n");
+
parm= func->cont.properties.first;
if(parm) fprintf(f, "\t{(PropertyRNA*)&rna_%s_%s_%s, ", srna->identifier, func->identifier, parm->identifier);
else fprintf(f, "\t{NULL, ");
@@ -1744,6 +1746,8 @@
if(srna->cont.prev) fprintf(f, "(ContainerRNA *)&RNA_%s,\n", ((StructRNA*)srna->cont.prev)->identifier);
else fprintf(f, "NULL,\n");
+ fprintf(f, "\tNULL,\n");
+
prop= srna->cont.properties.first;
if(prop) fprintf(f, "\t{(PropertyRNA*)&rna_%s_%s, ", srna->identifier, prop->identifier);
else fprintf(f, "\t{NULL, ");
Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c 2009-06-19 22:16:30 UTC (rev 21017)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c 2009-06-19 23:05:21 UTC (rev 21018)
@@ -32,6 +32,7 @@
#include "BLI_blenlib.h"
#include "BLI_dynstr.h"
+#include "BLI_ghash.h"
#include "BKE_context.h"
#include "BKE_idprop.h"
@@ -46,10 +47,35 @@
#include "rna_internal.h"
-/* Exit */
+/* Init/Exit */
+void RNA_init()
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ for(srna=BLENDER_RNA.structs.first; srna; srna=srna->cont.next) {
+ if(!srna->cont.prophash) {
+ srna->cont.prophash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp);
+
+ for(prop=srna->cont.properties.first; prop; prop=prop->next)
+ if(!(prop->flag & PROP_BUILTIN))
+ BLI_ghash_insert(srna->cont.prophash, (void*)prop->identifier, prop);
+ }
+ }
+}
+
void RNA_exit()
{
+ StructRNA *srna;
+
+ for(srna=BLENDER_RNA.structs.first; srna; srna=srna->cont.next) {
+ if(srna->cont.prophash) {
+ BLI_ghash_free(srna->cont.prophash, NULL, NULL);
+ srna->cont.prophash= NULL;
+ }
+ }
+
RNA_free(&BLENDER_RNA);
}
@@ -388,24 +414,13 @@
PropertyRNA *RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
{
- CollectionPropertyIterator iter;
- PropertyRNA *iterprop, *prop;
- int i = 0;
+ PropertyRNA *iterprop= RNA_struct_iterator_property(ptr->type);
+ PointerRNA propptr;
- iterprop= RNA_struct_iterator_property(ptr->type);
- RNA_property_collection_begin(ptr, iterprop, &iter);
- prop= NULL;
-
- for(; iter.valid; RNA_property_collection_next(&iter), i++) {
- if(strcmp(identifier, RNA_property_identifier(iter.ptr.data)) == 0) {
- prop= iter.ptr.data;
- break;
- }
- }
-
- RNA_property_collection_end(&iter);
-
- return prop;
+ if(RNA_property_collection_lookup_string(ptr, iterprop, identifier, &propptr))
+ return propptr.data;
+
+ return NULL;
}
/* Find the property which uses the given nested struct */
@@ -1643,13 +1658,19 @@
buf= MEM_callocN(sizeof(char)*(len+1), "rna_path_token");
/* copy string, taking into account escaped ] */
- for(p=*path, i=0, j=0; i<len; i++, p++) {
- if(*p == '\\' && *(p+1) == ']');
- else buf[j++]= *p;
+ if(bracket) {
+ for(p=*path, i=0, j=0; i<len; i++, p++) {
+ if(*p == '\\' && *(p+1) == ']');
+ else buf[j++]= *p;
+ }
+
+ buf[j]= 0;
}
+ else {
+ memcpy(buf, *path, sizeof(char)*len);
+ buf[len]= '\0';
+ }
- buf[j]= 0;
-
/* set path to start of next token */
if(*p == ']') p++;
if(*p == '.') p++;
@@ -1660,8 +1681,7 @@
int RNA_path_resolve(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
{
- CollectionPropertyIterator iter;
- PropertyRNA *prop, *iterprop;
+ PropertyRNA *prop;
PointerRNA curptr, nextptr;
char fixedbuf[256], *token;
int len, intkey;
@@ -1676,19 +1696,8 @@
if(!token)
return 0;
- iterprop= RNA_struct_iterator_property(curptr.type);
- RNA_property_collection_begin(&curptr, iterprop, &iter);
- prop= NULL;
+ prop= RNA_struct_find_property(&curptr, token);
- for(; iter.valid; RNA_property_collection_next(&iter)) {
- if(strcmp(token, RNA_property_identifier(iter.ptr.data)) == 0) {
- prop= iter.ptr.data;
- break;
- }
- }
-
- RNA_property_collection_end(&iter);
-
if(token != fixedbuf)
MEM_freeN(token);
Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_define.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_define.c 2009-06-19 22:16:30 UTC (rev 21017)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_define.c 2009-06-19 23:05:21 UTC (rev 21018)
@@ -38,6 +38,8 @@
#include "RNA_define.h"
#include "RNA_types.h"
+#include "BLI_ghash.h"
+
#include "rna_internal.h"
/* Global used during defining */
@@ -557,6 +559,7 @@
/* copy from struct to derive stuff, a bit clumsy since we can't
* use MEM_dupallocN, data structs may not be alloced but builtin */
memcpy(srna, srnafrom, sizeof(StructRNA));
+ srna->cont.prophash= NULL;
srna->cont.properties.first= srna->cont.properties.last= NULL;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list