[prev in list] [next in list] [prev in thread] [next in thread]
List: bzflag-commits
Subject: SF.net SVN: bzflag:[18467] trunk/bzwgen
From: chaos-dev () users ! sourceforge ! net
Date: 2008-08-24 19:37:16
Message-ID: E1KXLOm-0005As-HG () 3kljzd1 ! ch3 ! sourceforge ! com
[Download RAW message or body]
Revision: 18467
http://bzflag.svn.sourceforge.net/bzflag/?rev=18467&view=rev
Author: chaos-dev
Date: 2008-08-24 19:37:15 +0000 (Sun, 24 Aug 2008)
Log Message:
-----------
* added a lot more logging info, mainly for BuildZone and RuleSet
* style cleanup of the files
Modified Paths:
--------------
trunk/bzwgen/inc/graph/PlanarGraph.h
trunk/bzwgen/src/BuildZone.cxx
trunk/bzwgen/src/RuleSet.cxx
trunk/bzwgen/src/graph/PlanarGraph.cxx
Modified: trunk/bzwgen/inc/graph/PlanarGraph.h
===================================================================
--- trunk/bzwgen/inc/graph/PlanarGraph.h 2008-08-24 19:07:11 UTC (rev 18466)
+++ trunk/bzwgen/inc/graph/PlanarGraph.h 2008-08-24 19:37:15 UTC (rev 18467)
@@ -283,6 +283,8 @@
* is done via y coordinate.
*/
static bool compareNodesX ( const Node* a, const Node* b ) {
+ assert( a );
+ assert( b );
return (a->vector().x < b->vector().x || a->vector().y < b->vector().y );
}
/**
Modified: trunk/bzwgen/src/BuildZone.cxx
===================================================================
--- trunk/bzwgen/src/BuildZone.cxx 2008-08-24 19:07:11 UTC (rev 18466)
+++ trunk/bzwgen/src/BuildZone.cxx 2008-08-24 19:37:15 UTC (rev 18467)
@@ -19,27 +19,29 @@
graph::NodeVector nodes = face->getNodes();
- Face* swface = new Face();
- swface->setMaterial( 0 );
- for (size_t i = 0; i < nodes.size(); i++) {
- swface->addVertex(mesh->addVertex(Vertex(nodes[i]->vector().x,nodes[i]->vector().y,0.0f)));
+ Face* baseFace = new Face();
+ baseFace->setMaterial( 0 );
+ for ( size_t i = 0; i < nodes.size(); i++ ) {
+ baseFace->addVertex( mesh->addVertex( Vertex( nodes[i]->vector().x, \
nodes[i]->vector().y, 0.0f ) ) ); }
- int base = mesh->addFace(swface);
+ int baseFaceID = mesh->addFace( baseFace );
+ Logger.log( 4, "BuildZone : running ruleset 'start' rule..." );
String rulename = String("start");
- meshes = generator->getRuleSet()->run(mesh,base,rulename);
+ meshes = generator->getRuleSet()->run( mesh, baseFaceID, rulename );
+ Logger.log( 4, "BuildZone : complete" );
}
void BuildZone::output( Output& out ) {
if (meshes == NULL) return;
- for (MeshVectIter itr = meshes->begin(); itr!= meshes->end(); ++itr)
- (*itr)->output(out,generator->getRuleSet()->materialsCount());
+ for ( MeshVectIter itr = meshes->begin(); itr!= meshes->end(); ++itr )
+ (*itr)->output( out, generator->getRuleSet()->materialsCount() );
}
BuildZone::~BuildZone( ) {
- if (meshes == NULL) return;
- for (MeshVectIter itr = meshes->begin(); itr!= meshes->end(); ++itr)
+ if ( meshes == NULL ) return;
+ for ( MeshVectIter itr = meshes->begin(); itr!= meshes->end(); ++itr )
delete (*itr);
delete meshes;
}
Modified: trunk/bzwgen/src/RuleSet.cxx
===================================================================
--- trunk/bzwgen/src/RuleSet.cxx 2008-08-24 19:07:11 UTC (rev 18466)
+++ trunk/bzwgen/src/RuleSet.cxx 2008-08-24 19:37:15 UTC (rev 18467)
@@ -13,14 +13,14 @@
#include "RuleSet.h"
#include "globals.h"
-void RuleSet::addRule(String& name, Rule* rule) {
+void RuleSet::addRule( String& name, Rule* rule ) {
Logger.log( 3, "RuleSet : added rule '%s'.", rule->getName().c_str() );
rules[name] = rule;
}
-double RuleSet::getAttr(String& name) {
- AttributeMap::iterator itr = attrmap.find(name);
- if (itr == attrmap.end()) {
+double RuleSet::getAttr( String& name ) {
+ AttributeMap::iterator itr = attrmap.find( name );
+ if ( itr == attrmap.end() ) {
Logger.log( "RuleSet : Warning : attribute '%s' not found!", name.c_str() );
return 0.0;
}
@@ -30,31 +30,39 @@
int RuleSet::runMesh(Mesh* mesh, int face, String& rulename) {
- if (recursion == -1) return -1;
+ Logger.log( 4, "RuleSet : runMesh, rule '%s', recursion level %d", \
rulename.c_str(), recursion ); + if ( recursion == -1 ) return -1;
recursion++;
- if (recursion == MAX_RECURSION) {
+ if ( recursion == MAX_RECURSION ) {
recursion = -1;
Logger.log( "RuleSet : Warning : Recursion level 1000 reached! Are you sure you \
have no infinite loops?"); return -1;
}
- RuleMapIter itr = rules.find(rulename);
- if (itr == rules.end()) {
+ RuleMapIter itr = rules.find( rulename );
+ if ( itr == rules.end() ) {
Logger.log( "RuleSet : Warning : rule '%s' not found!", rulename.c_str() );
return -1;
}
- int result = itr->second->runMesh(mesh,face);
+ int result = itr->second->runMesh( mesh, face );
recursion--;
return result;
}
-MeshVector* RuleSet::run(Mesh* initial_mesh, int initial_face, String& rulename) {
+MeshVector* RuleSet::run( Mesh* initial_mesh, int initial_face, String& rulename ) {
+ assert( initial_mesh );
+ Logger.log( 4, "RuleSet : running rule '%s'", rulename.c_str() );
+ Vertex normal = initial_mesh->faceNormal( initial_face );
+ if ( normal.z <= 0.0 ) {
+ Logger.log( "RuleSet : run passed a face with bad normal : %s", \
normal.toString().c_str() ); + return NULL;
+ }
meshes = new MeshVector();
- meshes->push_back(initial_mesh);
- initial_mesh->pushBase(initial_face);
- initial_mesh->addInsideVertex(initial_mesh->faceCenter(initial_face)+initial_mesh->faceNormal(initial_face)*0.05f);
- if (runMesh(initial_mesh,initial_face,rulename) == -1)
+ meshes->push_back( initial_mesh );
+ initial_mesh->pushBase( initial_face );
+ initial_mesh->addInsideVertex( initial_mesh->faceCenter( initial_face ) + normal * \
0.05f ); + if ( runMesh( initial_mesh, initial_face, rulename ) == -1 )
Logger.log( "RuleSet : run failed with start rule '%s!'", rulename.c_str() );
return meshes;
}
Modified: trunk/bzwgen/src/graph/PlanarGraph.cxx
===================================================================
--- trunk/bzwgen/src/graph/PlanarGraph.cxx 2008-08-24 19:07:11 UTC (rev 18466)
+++ trunk/bzwgen/src/graph/PlanarGraph.cxx 2008-08-24 19:37:15 UTC (rev 18467)
@@ -18,8 +18,10 @@
namespace graph {
void PlanarGraph::readFaces() {
+ Logger.log( 4, "PlanarGraph : readFaces" );
// Create a sorted list of Nodes by the x coordinate.
NodeVector xnodes = nodeList.getCopy();
+ Logger.log( 4, "PlanarGraph : readFaces, sorting %d nodes...", xnodes.size() \
); std::sort( xnodes.begin(), xnodes.end(), compareNodesX );
// Perform a sweep while reading faces
Logger.log( 4, "PlanarGraph : reading faces from %d nodes", xnodes.size() );
This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
BZFlag-commits mailing list
BZFlag-commits@lists.SourceForge.net
https://lists.SourceForge.net/lists/listinfo/bzflag-commits
irc: #BZFlag @ irc.freenode.net
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic