Explorar o código

Removed old entries

Ivan Safrin %!s(int64=15) %!d(string=hai) anos
pai
achega
439c7eb831

+ 0 - 1297
Core/Contents/Source/xmltest.cpp

@@ -1,1297 +0,0 @@
-/*
-   Test program for TinyXML.
-*/
-
-
-#ifdef TIXML_USE_STL
-	#include <iostream>
-	#include <sstream>
-	using namespace std;
-#else
-	#include <stdio.h>
-#endif
-
-#if defined( WIN32 ) && defined( TUNE )
-	#include <crtdbg.h>
-	_CrtMemState startMemState;
-	_CrtMemState endMemState;
-#endif
-
-#include "tinyxml.h"
-
-
-static int gPass = 0;
-static int gFail = 0;
-
-using namespace Polycode;
-
-
-bool XmlTest (const char* testString, const char* expected, const char* found, bool noEcho = false)
-{
-	bool pass = !strcmp( expected, found );
-	if ( pass )
-		Logger::log ("[pass]");
-	else
-		Logger::log ("[fail]");
-
-	if ( noEcho )
-		Logger::log (" %s\n", testString);
-	else
-		Logger::log (" %s [%s][%s]\n", testString, expected, found);
-
-	if ( pass )
-		++gPass;
-	else
-		++gFail;
-	return pass;
-}
-
-
-bool XmlTest( const char* testString, int expected, int found, bool noEcho = false )
-{
-	bool pass = ( expected == found );
-	if ( pass )
-		Logger::log ("[pass]");
-	else
-		Logger::log ("[fail]");
-
-	if ( noEcho )
-		Logger::log (" %s\n", testString);
-	else
-		Logger::log (" %s [%d][%d]\n", testString, expected, found);
-
-	if ( pass )
-		++gPass;
-	else
-		++gFail;
-	return pass;
-}
-
-
-//
-// This file demonstrates some basic functionality of TinyXml.
-// Note that the example is very contrived. It presumes you know
-// what is in the XML file. But it does test the basic operations,
-// and show how to add and remove nodes.
-//
-
-int main()
-{
-	//
-	// We start with the 'demoStart' todo list. Process it. And
-	// should hopefully end up with the todo list as illustrated.
-	//
-	const char* demoStart =
-		"<?xml version=\"1.0\"  standalone='no' >\n"
-		"<!-- Our to do list data -->"
-		"<ToDo>\n"
-		"<!-- Do I need a secure PDA? -->\n"
-		"<Item priority=\"1\" distance='close'> Go to the <bold>Toy store!</bold></Item>"
-		"<Item priority=\"2\" distance='none'> Do bills   </Item>"
-		"<Item priority=\"2\" distance='far &amp; back'> Look for Evil Dinosaurs! </Item>"
-		"</ToDo>";
-		
-	{
-
-	#ifdef TIXML_USE_STL
-		/*	What the todo list should look like after processing.
-			In stream (no formatting) representation. */
-		const char* demoEnd =
-			"<?xml version=\"1.0\" standalone=\"no\" ?>"
-			"<!-- Our to do list data -->"
-			"<ToDo>"
-			"<!-- Do I need a secure PDA? -->"
-			"<Item priority=\"2\" distance=\"close\">Go to the"
-			"<bold>Toy store!"
-			"</bold>"
-			"</Item>"
-			"<Item priority=\"1\" distance=\"far\">Talk to:"
-			"<Meeting where=\"School\">"
-			"<Attendee name=\"Marple\" position=\"teacher\" />"
-			"<Attendee name=\"Voel\" position=\"counselor\" />"
-			"</Meeting>"
-			"<Meeting where=\"Lunch\" />"
-			"</Item>"
-			"<Item priority=\"2\" distance=\"here\">Do bills"
-			"</Item>"
-			"</ToDo>";
-	#endif
-
-		// The example parses from the character string (above):
-		#if defined( WIN32 ) && defined( TUNE )
-		_CrtMemCheckpoint( &startMemState );
-		#endif	
-
-		{
-			// Write to a file and read it back, to check file I/O.
-
-			TiXmlDocument doc( "demotest.xml" );
-			doc.Parse( demoStart );
-
-			if ( doc.Error() )
-			{
-				Logger::log( "Error in %s: %s\n", doc.Value(), doc.ErrorDesc() );
-				exit( 1 );
-			}
-			doc.SaveFile();
-		}
-
-		TiXmlDocument doc( "demotest.xml" );
-		bool loadOkay = doc.LoadFile();
-
-		if ( !loadOkay )
-		{
-			Logger::log( "Could not load test file 'demotest.xml'. Error='%s'. Exiting.\n", doc.ErrorDesc() );
-			exit( 1 );
-		}
-
-		Logger::log( "** Demo doc read from disk: ** \n\n" );
-		Logger::log( "** Printing via doc.Print **\n" );
-		doc.Print( stdout );
-
-		{
-			Logger::log( "** Printing via TiXmlPrinter **\n" );
-			TiXmlPrinter printer;
-			doc.Accept( &printer );
-//			fLogger::log( stdout, "%s", printer.CStr() );
-		}
-		#ifdef TIXML_USE_STL	
-		{
-			Logger::log( "** Printing via operator<< **\n" );
-			std::cout << doc;
-		}
-		#endif
-		TiXmlNode* node = 0;
-		TiXmlElement* todoElement = 0;
-		TiXmlElement* itemElement = 0;
-
-
-		// --------------------------------------------------------
-		// An example of changing existing attributes, and removing
-		// an element from the document.
-		// --------------------------------------------------------
-
-		// Get the "ToDo" element.
-		// It is a child of the document, and can be selected by name.
-		node = doc.FirstChild( "ToDo" );
-		assert( node );
-		todoElement = node->ToElement();
-		assert( todoElement  );
-
-		// Going to the toy store is now our second priority...
-		// So set the "priority" attribute of the first item in the list.
-		node = todoElement->FirstChildElement();	// This skips the "PDA" comment.
-		assert( node );
-		itemElement = node->ToElement();
-		assert( itemElement  );
-		itemElement->SetAttribute( "priority", 2 );
-
-		// Change the distance to "doing bills" from
-		// "none" to "here". It's the next sibling element.
-		itemElement = itemElement->NextSiblingElement();
-		assert( itemElement );
-		itemElement->SetAttribute( "distance", "here" );
-
-		// Remove the "Look for Evil Dinosaurs!" item.
-		// It is 1 more sibling away. We ask the parent to remove
-		// a particular child.
-		itemElement = itemElement->NextSiblingElement();
-		todoElement->RemoveChild( itemElement );
-
-		itemElement = 0;
-
-		// --------------------------------------------------------
-		// What follows is an example of created elements and text
-		// nodes and adding them to the document.
-		// --------------------------------------------------------
-
-		// Add some meetings.
-		TiXmlElement item( "Item" );
-		item.SetAttribute( "priority", "1" );
-		item.SetAttribute( "distance", "far" );
-
-		TiXmlText text( "Talk to:" );
-
-		TiXmlElement meeting1( "Meeting" );
-		meeting1.SetAttribute( "where", "School" );
-
-		TiXmlElement meeting2( "Meeting" );
-		meeting2.SetAttribute( "where", "Lunch" );
-
-		TiXmlElement attendee1( "Attendee" );
-		attendee1.SetAttribute( "name", "Marple" );
-		attendee1.SetAttribute( "position", "teacher" );
-
-		TiXmlElement attendee2( "Attendee" );
-		attendee2.SetAttribute( "name", "Voel" );
-		attendee2.SetAttribute( "position", "counselor" );
-
-		// Assemble the nodes we've created:
-		meeting1.InsertEndChild( attendee1 );
-		meeting1.InsertEndChild( attendee2 );
-
-		item.InsertEndChild( text );
-		item.InsertEndChild( meeting1 );
-		item.InsertEndChild( meeting2 );
-
-		// And add the node to the existing list after the first child.
-		node = todoElement->FirstChild( "Item" );
-		assert( node );
-		itemElement = node->ToElement();
-		assert( itemElement );
-
-		todoElement->InsertAfterChild( itemElement, item );
-
-		Logger::log( "\n** Demo doc processed: ** \n\n" );
-		doc.Print( stdout );
-
-
-	#ifdef TIXML_USE_STL
-		Logger::log( "** Demo doc processed to stream: ** \n\n" );
-		cout << doc << endl << endl;
-	#endif
-
-		// --------------------------------------------------------
-		// Different tests...do we have what we expect?
-		// --------------------------------------------------------
-
-		int count = 0;
-		TiXmlElement*	element;
-
-		//////////////////////////////////////////////////////
-
-	#ifdef TIXML_USE_STL
-		cout << "** Basic structure. **\n";
-		ostringstream outputStream( ostringstream::out );
-		outputStream << doc;
-		XmlTest( "Output stream correct.",	string( demoEnd ).c_str(),
-											outputStream.str().c_str(), true );
-	#endif
-
-		node = doc.RootElement();
-		assert( node );
-		XmlTest( "Root element exists.", true, ( node != 0 && node->ToElement() ) );
-		XmlTest ( "Root element value is 'ToDo'.", "ToDo",  node->Value());
-
-		node = node->FirstChild();
-		XmlTest( "First child exists & is a comment.", true, ( node != 0 && node->ToComment() ) );
-		node = node->NextSibling();
-		XmlTest( "Sibling element exists & is an element.", true, ( node != 0 && node->ToElement() ) );
-		XmlTest ( "Value is 'Item'.", "Item", node->Value() );
-
-		node = node->FirstChild();
-		XmlTest ( "First child exists.", true, ( node != 0 && node->ToText() ) );
-		XmlTest ( "Value is 'Go to the'.", "Go to the", node->Value() );
-
-
-		//////////////////////////////////////////////////////
-		Logger::log ("\n** Iterators. **\n");
-
-		// Walk all the top level nodes of the document.
-		count = 0;
-		for( node = doc.FirstChild();
-			 node;
-			 node = node->NextSibling() )
-		{
-			count++;
-		}
-		XmlTest( "Top level nodes, using First / Next.", 3, count );
-
-		count = 0;
-		for( node = doc.LastChild();
-			 node;
-			 node = node->PreviousSibling() )
-		{
-			count++;
-		}
-		XmlTest( "Top level nodes, using Last / Previous.", 3, count );
-
-		// Walk all the top level nodes of the document,
-		// using a different syntax.
-		count = 0;
-		for( node = doc.IterateChildren( 0 );
-			 node;
-			 node = doc.IterateChildren( node ) )
-		{
-			count++;
-		}
-		XmlTest( "Top level nodes, using IterateChildren.", 3, count );
-
-		// Walk all the elements in a node.
-		count = 0;
-		for( element = todoElement->FirstChildElement();
-			 element;
-			 element = element->NextSiblingElement() )
-		{
-			count++;
-		}
-		XmlTest( "Children of the 'ToDo' element, using First / Next.",
-			3, count );
-
-		// Walk all the elements in a node by value.
-		count = 0;
-		for( node = todoElement->FirstChild( "Item" );
-			 node;
-			 node = node->NextSibling( "Item" ) )
-		{
-			count++;
-		}
-		XmlTest( "'Item' children of the 'ToDo' element, using First/Next.", 3, count );
-
-		count = 0;
-		for( node = todoElement->LastChild( "Item" );
-			 node;
-			 node = node->PreviousSibling( "Item" ) )
-		{
-			count++;
-		}
-		XmlTest( "'Item' children of the 'ToDo' element, using Last/Previous.", 3, count );
-
-	#ifdef TIXML_USE_STL
-		{
-			cout << "\n** Parsing. **\n";
-			istringstream parse0( "<Element0 attribute0='foo0' attribute1= noquotes attribute2 = '&gt;' />" );
-			TiXmlElement element0( "default" );
-			parse0 >> element0;
-
-			XmlTest ( "Element parsed, value is 'Element0'.", "Element0", element0.Value() );
-			XmlTest ( "Reads attribute 'attribute0=\"foo0\"'.", "foo0", element0.Attribute( "attribute0" ));
-			XmlTest ( "Reads incorrectly formatted 'attribute1=noquotes'.", "noquotes", element0.Attribute( "attribute1" ) );
-			XmlTest ( "Read attribute with entity value '>'.", ">", element0.Attribute( "attribute2" ) );
-		}
-	#endif
-
-		{
-			const char* error =	"<?xml version=\"1.0\" standalone=\"no\" ?>\n"
-								"<passages count=\"006\" formatversion=\"20020620\">\n"
-								"    <wrong error>\n"
-								"</passages>";
-
-			TiXmlDocument docTest;
-			docTest.Parse( error );
-			XmlTest( "Error row", docTest.ErrorRow(), 3 );
-			XmlTest( "Error column", docTest.ErrorCol(), 17 );
-			//Logger::log( "error=%d id='%s' row %d col%d\n", (int) doc.Error(), doc.ErrorDesc(), doc.ErrorRow()+1, doc.ErrorCol() + 1 );
-
-		}
-
-	#ifdef TIXML_USE_STL
-		{
-			//////////////////////////////////////////////////////
-			cout << "\n** Streaming. **\n";
-
-			// Round trip check: stream in, then stream back out to verify. The stream
-			// out has already been checked, above. We use the output
-
-			istringstream inputStringStream( outputStream.str() );
-			TiXmlDocument document0;
-
-			inputStringStream >> document0;
-
-			ostringstream outputStream0( ostringstream::out );
-			outputStream0 << document0;
-
-			XmlTest( "Stream round trip correct.",	string( demoEnd ).c_str(), 
-													outputStream0.str().c_str(), true );
-
-			std::string str;
-			str << document0;
-
-			XmlTest( "String printing correct.", string( demoEnd ).c_str(), 
-												 str.c_str(), true );
-		}
-	#endif
-	}
-	
-	{
-		const char* str = "<doc attr0='1' attr1='2.0' attr2='foo' />";
-
-		TiXmlDocument doc;
-		doc.Parse( str );
-
-		TiXmlElement* ele = doc.FirstChildElement();
-
-		int iVal, result;
-		double dVal;
-
-		result = ele->QueryDoubleAttribute( "attr0", &dVal );
-		XmlTest( "Query attribute: int as double", result, TIXML_SUCCESS );
-		XmlTest( "Query attribute: int as double", (int)dVal, 1 );
-		result = ele->QueryDoubleAttribute( "attr1", &dVal );
-		XmlTest( "Query attribute: double as double", (int)dVal, 2 );
-		result = ele->QueryIntAttribute( "attr1", &iVal );
-		XmlTest( "Query attribute: double as int", result, TIXML_SUCCESS );
-		XmlTest( "Query attribute: double as int", iVal, 2 );
-		result = ele->QueryIntAttribute( "attr2", &iVal );
-		XmlTest( "Query attribute: not a number", result, TIXML_WRONG_TYPE );
-		result = ele->QueryIntAttribute( "bar", &iVal );
-		XmlTest( "Query attribute: does not exist", result, TIXML_NO_ATTRIBUTE );
-	}
-	
-	{
-		const char* str =	"\t<?xml version=\"1.0\" standalone=\"no\" ?>\t<room doors='2'>\n"
-							"</room>";
-
-		TiXmlDocument doc;
-		doc.SetTabSize( 8 );
-		doc.Parse( str );
-
-		TiXmlHandle docHandle( &doc );
-		TiXmlHandle roomHandle = docHandle.FirstChildElement( "room" );
-
-		assert( docHandle.Node() );
-		assert( roomHandle.Element() );
-
-		TiXmlElement* room = roomHandle.Element();
-		assert( room );
-		TiXmlAttribute* doors = room->FirstAttribute();
-		assert( doors );
-
-		XmlTest( "Location tracking: Tab 8: room row", room->Row(), 1 );
-		XmlTest( "Location tracking: Tab 8: room col", room->Column(), 49 );
-		XmlTest( "Location tracking: Tab 8: doors row", doors->Row(), 1 );
-		XmlTest( "Location tracking: Tab 8: doors col", doors->Column(), 55 );
-	}
-	
-	{
-		const char* str =	"\t<?xml version=\"1.0\" standalone=\"no\" ?>\t<room doors='2'>\n"
-							"  <!-- Silly example -->\n"
-							"    <door wall='north'>A great door!</door>\n"
-							"\t<door wall='east'/>"
-							"</room>";
-
-		TiXmlDocument doc;
-		doc.Parse( str );
-
-		TiXmlHandle docHandle( &doc );
-		TiXmlHandle roomHandle = docHandle.FirstChildElement( "room" );
-		TiXmlHandle commentHandle = docHandle.FirstChildElement( "room" ).FirstChild();
-		TiXmlHandle textHandle = docHandle.FirstChildElement( "room" ).ChildElement( "door", 0 ).FirstChild();
-		TiXmlHandle door0Handle = docHandle.FirstChildElement( "room" ).ChildElement( 0 );
-		TiXmlHandle door1Handle = docHandle.FirstChildElement( "room" ).ChildElement( 1 );
-
-		assert( docHandle.Node() );
-		assert( roomHandle.Element() );
-		assert( commentHandle.Node() );
-		assert( textHandle.Text() );
-		assert( door0Handle.Element() );
-		assert( door1Handle.Element() );
-
-		TiXmlDeclaration* declaration = doc.FirstChild()->ToDeclaration();
-		assert( declaration );
-		TiXmlElement* room = roomHandle.Element();
-		assert( room );
-		TiXmlAttribute* doors = room->FirstAttribute();
-		assert( doors );
-		TiXmlText* text = textHandle.Text();
-		TiXmlComment* comment = commentHandle.Node()->ToComment();
-		assert( comment );
-		TiXmlElement* door0 = door0Handle.Element();
-		TiXmlElement* door1 = door1Handle.Element();
-
-		XmlTest( "Location tracking: Declaration row", declaration->Row(), 1 );
-		XmlTest( "Location tracking: Declaration col", declaration->Column(), 5 );
-		XmlTest( "Location tracking: room row", room->Row(), 1 );
-		XmlTest( "Location tracking: room col", room->Column(), 45 );
-		XmlTest( "Location tracking: doors row", doors->Row(), 1 );
-		XmlTest( "Location tracking: doors col", doors->Column(), 51 );
-		XmlTest( "Location tracking: Comment row", comment->Row(), 2 );
-		XmlTest( "Location tracking: Comment col", comment->Column(), 3 );
-		XmlTest( "Location tracking: text row", text->Row(), 3 ); 
-		XmlTest( "Location tracking: text col", text->Column(), 24 );
-		XmlTest( "Location tracking: door0 row", door0->Row(), 3 );
-		XmlTest( "Location tracking: door0 col", door0->Column(), 5 );
-		XmlTest( "Location tracking: door1 row", door1->Row(), 4 );
-		XmlTest( "Location tracking: door1 col", door1->Column(), 5 );
-	}
-
-
-	// --------------------------------------------------------
-	// UTF-8 testing. It is important to test:
-	//	1. Making sure name, value, and text read correctly
-	//	2. Row, Col functionality
-	//	3. Correct output
-	// --------------------------------------------------------
-	Logger::log ("\n** UTF-8 **\n");
-	{
-		TiXmlDocument doc( "utf8test.xml" );
-		doc.LoadFile();
-		if ( doc.Error() && doc.ErrorId() == TiXmlBase::TIXML_ERROR_OPENING_FILE ) {
-			Logger::log( "WARNING: File 'utf8test.xml' not found.\n"
-					"(Are you running the test from the wrong directory?)\n"
-				    "Could not test UTF-8 functionality.\n" );
-		}
-		else
-		{
-			TiXmlHandle docH( &doc );
-			// Get the attribute "value" from the "Russian" element and check it.
-			TiXmlElement* element = docH.FirstChildElement( "document" ).FirstChildElement( "Russian" ).Element();
-			const unsigned char correctValue[] = {	0xd1U, 0x86U, 0xd0U, 0xb5U, 0xd0U, 0xbdU, 0xd0U, 0xbdU, 
-													0xd0U, 0xbeU, 0xd1U, 0x81U, 0xd1U, 0x82U, 0xd1U, 0x8cU, 0 };
-
-			XmlTest( "UTF-8: Russian value.", (const char*)correctValue, element->Attribute( "value" ), true );
-			XmlTest( "UTF-8: Russian value row.", 4, element->Row() );
-			XmlTest( "UTF-8: Russian value column.", 5, element->Column() );
-
-			const unsigned char russianElementName[] = {	0xd0U, 0xa0U, 0xd1U, 0x83U,
-															0xd1U, 0x81U, 0xd1U, 0x81U,
-															0xd0U, 0xbaU, 0xd0U, 0xb8U,
-															0xd0U, 0xb9U, 0 };
-			const char russianText[] = "<\xD0\xB8\xD0\xBC\xD0\xB5\xD0\xB5\xD1\x82>";
-
-			TiXmlText* text = docH.FirstChildElement( "document" ).FirstChildElement( (const char*) russianElementName ).Child( 0 ).Text();
-			XmlTest( "UTF-8: Browsing russian element name.",
-					 russianText,
-					 text->Value(),
-					 true );
-			XmlTest( "UTF-8: Russian element name row.", 7, text->Row() );
-			XmlTest( "UTF-8: Russian element name column.", 47, text->Column() );
-
-			TiXmlDeclaration* dec = docH.Child( 0 ).Node()->ToDeclaration();
-			XmlTest( "UTF-8: Declaration column.", 1, dec->Column() );
-			XmlTest( "UTF-8: Document column.", 1, doc.Column() );
-
-			// Now try for a round trip.
-			doc.SaveFile( "utf8testout.xml" );
-
-			// Check the round trip.
-			char savedBuf[256];
-			char verifyBuf[256];
-			int okay = 1;
-
-			FILE* saved  = fopen( "utf8testout.xml", "r" );
-			FILE* verify = fopen( "utf8testverify.xml", "r" );
-			if ( saved && verify )
-			{
-				while ( fgets( verifyBuf, 256, verify ) )
-				{
-					fgets( savedBuf, 256, saved );
-					if ( strcmp( verifyBuf, savedBuf ) )
-					{
-						okay = 0;
-						break;
-					}
-				}
-				fclose( saved );
-				fclose( verify );
-			}
-			XmlTest( "UTF-8: Verified multi-language round trip.", 1, okay );
-
-			// On most Western machines, this is an element that contains
-			// the word "resume" with the correct accents, in a latin encoding.
-			// It will be something else completely on non-wester machines,
-			// which is why TinyXml is switching to UTF-8.
-			const char latin[] = "<element>r\x82sum\x82</element>";
-
-			TiXmlDocument latinDoc;
-			latinDoc.Parse( latin, 0, TIXML_ENCODING_LEGACY );
-
-			text = latinDoc.FirstChildElement()->FirstChild()->ToText();
-			XmlTest( "Legacy encoding: Verify text element.", "r\x82sum\x82", text->Value() );
-		}
-	}		
-
-	//////////////////////
-	// Copy and assignment
-	//////////////////////
-	Logger::log ("\n** Copy and Assignment **\n");
-	{
-		TiXmlElement element( "foo" );
-		element.Parse( "<element name='value' />", 0, TIXML_ENCODING_UNKNOWN );
-
-		TiXmlElement elementCopy( element );
-		TiXmlElement elementAssign( "foo" );
-		elementAssign.Parse( "<incorrect foo='bar'/>", 0, TIXML_ENCODING_UNKNOWN );
-		elementAssign = element;
-
-		XmlTest( "Copy/Assign: element copy #1.", "element", elementCopy.Value() );
-		XmlTest( "Copy/Assign: element copy #2.", "value", elementCopy.Attribute( "name" ) );
-		XmlTest( "Copy/Assign: element assign #1.", "element", elementAssign.Value() );
-		XmlTest( "Copy/Assign: element assign #2.", "value", elementAssign.Attribute( "name" ) );
-		XmlTest( "Copy/Assign: element assign #3.", true, ( 0 == elementAssign.Attribute( "foo" )) );
-
-		TiXmlComment comment;
-		comment.Parse( "<!--comment-->", 0, TIXML_ENCODING_UNKNOWN );
-		TiXmlComment commentCopy( comment );
-		TiXmlComment commentAssign;
-		commentAssign = commentCopy;
-		XmlTest( "Copy/Assign: comment copy.", "comment", commentCopy.Value() );
-		XmlTest( "Copy/Assign: comment assign.", "comment", commentAssign.Value() );
-
-		TiXmlUnknown unknown;
-		unknown.Parse( "<[unknown]>", 0, TIXML_ENCODING_UNKNOWN );
-		TiXmlUnknown unknownCopy( unknown );
-		TiXmlUnknown unknownAssign;
-		unknownAssign.Parse( "incorrect", 0, TIXML_ENCODING_UNKNOWN );
-		unknownAssign = unknownCopy;
-		XmlTest( "Copy/Assign: unknown copy.", "[unknown]", unknownCopy.Value() );
-		XmlTest( "Copy/Assign: unknown assign.", "[unknown]", unknownAssign.Value() );
-		
-		TiXmlText text( "TextNode" );
-		TiXmlText textCopy( text );
-		TiXmlText textAssign( "incorrect" );
-		textAssign = text;
-		XmlTest( "Copy/Assign: text copy.", "TextNode", textCopy.Value() );
-		XmlTest( "Copy/Assign: text assign.", "TextNode", textAssign.Value() );
-
-		TiXmlDeclaration dec;
-		dec.Parse( "<?xml version='1.0' encoding='UTF-8'?>", 0, TIXML_ENCODING_UNKNOWN );
-		TiXmlDeclaration decCopy( dec );
-		TiXmlDeclaration decAssign;
-		decAssign = dec;
-
-		XmlTest( "Copy/Assign: declaration copy.", "UTF-8", decCopy.Encoding() );
-		XmlTest( "Copy/Assign: text assign.", "UTF-8", decAssign.Encoding() );
-
-		TiXmlDocument doc;
-		elementCopy.InsertEndChild( textCopy );
-		doc.InsertEndChild( decAssign );
-		doc.InsertEndChild( elementCopy );
-		doc.InsertEndChild( unknownAssign );
-
-		TiXmlDocument docCopy( doc );
-		TiXmlDocument docAssign;
-		docAssign = docCopy;
-
-		#ifdef TIXML_USE_STL
-		std::string original, copy, assign;
-		original << doc;
-		copy << docCopy;
-		assign << docAssign;
-		XmlTest( "Copy/Assign: document copy.", original.c_str(), copy.c_str(), true );
-		XmlTest( "Copy/Assign: document assign.", original.c_str(), assign.c_str(), true );
-
-		#endif
-	}	
-
-	//////////////////////////////////////////////////////
-#ifdef TIXML_USE_STL
-	Logger::log ("\n** Parsing, no Condense Whitespace **\n");
-	TiXmlBase::SetCondenseWhiteSpace( false );
-	{
-		istringstream parse1( "<start>This  is    \ntext</start>" );
-		TiXmlElement text1( "text" );
-		parse1 >> text1;
-
-		XmlTest ( "Condense white space OFF.", "This  is    \ntext",
-					text1.FirstChild()->Value(),
-					true );
-	}
-	TiXmlBase::SetCondenseWhiteSpace( true );
-#endif
-
-	//////////////////////////////////////////////////////
-	// GetText();
-	{
-		const char* str = "<foo>This is text</foo>";
-		TiXmlDocument doc;
-		doc.Parse( str );
-		const TiXmlElement* element = doc.RootElement();
-
-		XmlTest( "GetText() normal use.", "This is text", element->GetText() );
-
-		str = "<foo><b>This is text</b></foo>";
-		doc.Clear();
-		doc.Parse( str );
-		element = doc.RootElement();
-
-		XmlTest( "GetText() contained element.", element->GetText() == 0, true );
-
-		str = "<foo>This is <b>text</b></foo>";
-		doc.Clear();
-		TiXmlBase::SetCondenseWhiteSpace( false );
-		doc.Parse( str );
-		TiXmlBase::SetCondenseWhiteSpace( true );
-		element = doc.RootElement();
-
-		XmlTest( "GetText() partial.", "This is ", element->GetText() );
-	}
-
-
-	//////////////////////////////////////////////////////
-	// CDATA
-	{
-		const char* str =	"<xmlElement>"
-								"<![CDATA["
-									"I am > the rules!\n"
-									"...since I make symbolic puns"
-								"]]>"
-							"</xmlElement>";
-		TiXmlDocument doc;
-		doc.Parse( str );
-		doc.Print();
-
-		XmlTest( "CDATA parse.", doc.FirstChildElement()->FirstChild()->Value(), 
-								 "I am > the rules!\n...since I make symbolic puns",
-								 true );
-
-		#ifdef TIXML_USE_STL
-		//cout << doc << '\n';
-
-		doc.Clear();
-
-		istringstream parse0( str );
-		parse0 >> doc;
-		//cout << doc << '\n';
-
-		XmlTest( "CDATA stream.", doc.FirstChildElement()->FirstChild()->Value(), 
-								 "I am > the rules!\n...since I make symbolic puns",
-								 true );
-		#endif
-
-		TiXmlDocument doc1 = doc;
-		//doc.Print();
-
-		XmlTest( "CDATA copy.", doc1.FirstChildElement()->FirstChild()->Value(), 
-								 "I am > the rules!\n...since I make symbolic puns",
-								 true );
-	}
-	{
-		// [ 1482728 ] Wrong wide char parsing
-		char buf[256];
-		buf[255] = 0;
-		for( int i=0; i<255; ++i ) {
-			buf[i] = (char)((i>=32) ? i : 32);
-		}
-		TIXML_STRING str( "<xmlElement><![CDATA[" );
-		str += buf;
-		str += "]]></xmlElement>";
-
-		TiXmlDocument doc;
-		doc.Parse( str.c_str() );
-
-		TiXmlPrinter printer;
-		printer.SetStreamPrinting();
-		doc.Accept( &printer );
-
-		XmlTest( "CDATA with all bytes #1.", str.c_str(), printer.CStr(), true );
-
-		#ifdef TIXML_USE_STL
-		doc.Clear();
-		istringstream iss( printer.Str() );
-		iss >> doc;
-		std::string out;
-		out << doc;
-		XmlTest( "CDATA with all bytes #2.", out.c_str(), printer.CStr(), true );
-		#endif
-	}
-	{
-		// [ 1480107 ] Bug-fix for STL-streaming of CDATA that contains tags
-		// CDATA streaming had a couple of bugs, that this tests for.
-		const char* str =	"<xmlElement>"
-								"<![CDATA["
-									"<b>I am > the rules!</b>\n"
-									"...since I make symbolic puns"
-								"]]>"
-							"</xmlElement>";
-		TiXmlDocument doc;
-		doc.Parse( str );
-		doc.Print();
-
-		XmlTest( "CDATA parse. [ 1480107 ]", doc.FirstChildElement()->FirstChild()->Value(), 
-								 "<b>I am > the rules!</b>\n...since I make symbolic puns",
-								 true );
-
-		#ifdef TIXML_USE_STL
-
-		doc.Clear();
-
-		istringstream parse0( str );
-		parse0 >> doc;
-
-		XmlTest( "CDATA stream. [ 1480107 ]", doc.FirstChildElement()->FirstChild()->Value(), 
-								 "<b>I am > the rules!</b>\n...since I make symbolic puns",
-								 true );
-		#endif
-
-		TiXmlDocument doc1 = doc;
-		//doc.Print();
-
-		XmlTest( "CDATA copy. [ 1480107 ]", doc1.FirstChildElement()->FirstChild()->Value(), 
-								 "<b>I am > the rules!</b>\n...since I make symbolic puns",
-								 true );
-	}
-	//////////////////////////////////////////////////////
-	// Visit()
-
-
-
-	//////////////////////////////////////////////////////
-	Logger::log( "\n** Fuzzing... **\n" );
-
-	const int FUZZ_ITERATION = 300;
-
-	// The only goal is not to crash on bad input.
-	int len = (int) strlen( demoStart );
-	for( int i=0; i<FUZZ_ITERATION; ++i ) 
-	{
-		char* demoCopy = new char[ len+1 ];
-		strcpy( demoCopy, demoStart );
-
-		demoCopy[ i%len ] = (char)((i+1)*3);
-		demoCopy[ (i*7)%len ] = '>';
-		demoCopy[ (i*11)%len ] = '<';
-
-		TiXmlDocument xml;
-		xml.Parse( demoCopy );
-
-		delete [] demoCopy;
-	}
-	Logger::log( "** Fuzzing Complete. **\n" );
-	
-	//////////////////////////////////////////////////////
-	Logger::log ("\n** Bug regression tests **\n");
-
-	// InsertBeforeChild and InsertAfterChild causes crash.
-	{
-		TiXmlElement parent( "Parent" );
-		TiXmlElement childText0( "childText0" );
-		TiXmlElement childText1( "childText1" );
-		TiXmlNode* childNode0 = parent.InsertEndChild( childText0 );
-		TiXmlNode* childNode1 = parent.InsertBeforeChild( childNode0, childText1 );
-
-		XmlTest( "Test InsertBeforeChild on empty node.", ( childNode1 == parent.FirstChild() ), true );
-	}
-
-	{
-		// InsertBeforeChild and InsertAfterChild causes crash.
-		TiXmlElement parent( "Parent" );
-		TiXmlElement childText0( "childText0" );
-		TiXmlElement childText1( "childText1" );
-		TiXmlNode* childNode0 = parent.InsertEndChild( childText0 );
-		TiXmlNode* childNode1 = parent.InsertAfterChild( childNode0, childText1 );
-
-		XmlTest( "Test InsertAfterChild on empty node. ", ( childNode1 == parent.LastChild() ), true );
-	}
-
-	// Reports of missing constructors, irregular string problems.
-	{
-		// Missing constructor implementation. No test -- just compiles.
-		TiXmlText text( "Missing" );
-
-		#ifdef TIXML_USE_STL
-			// Missing implementation:
-			TiXmlDocument doc;
-			string name = "missing";
-			doc.LoadFile( name );
-
-			TiXmlText textSTL( name );
-		#else
-			// verifying some basic string functions:
-			TiXmlString a;
-			TiXmlString b( "Hello" );
-			TiXmlString c( "ooga" );
-
-			c = " World!";
-			a = b;
-			a += c;
-			a = a;
-
-			XmlTest( "Basic TiXmlString test. ", "Hello World!", a.c_str() );
-		#endif
- 	}
-
-	// Long filenames crashing STL version
-	{
-		TiXmlDocument doc( "midsummerNightsDreamWithAVeryLongFilenameToConfuseTheStringHandlingRoutines.xml" );
-		bool loadOkay = doc.LoadFile();
-		loadOkay = true;	// get rid of compiler warning.
-		// Won't pass on non-dev systems. Just a "no crash" check.
-		//XmlTest( "Long filename. ", true, loadOkay );
-	}
-
-	{
-		// Entities not being written correctly.
-		// From Lynn Allen
-
-		const char* passages =
-			"<?xml version=\"1.0\" standalone=\"no\" ?>"
-			"<passages count=\"006\" formatversion=\"20020620\">"
-				"<psg context=\"Line 5 has &quot;quotation marks&quot; and &apos;apostrophe marks&apos;."
-				" It also has &lt;, &gt;, and &amp;, as well as a fake copyright &#xA9;.\"> </psg>"
-			"</passages>";
-
-		TiXmlDocument doc( "passages.xml" );
-		doc.Parse( passages );
-		TiXmlElement* psg = doc.RootElement()->FirstChildElement();
-		const char* context = psg->Attribute( "context" );
-		const char* expected = "Line 5 has \"quotation marks\" and 'apostrophe marks'. It also has <, >, and &, as well as a fake copyright \xC2\xA9.";
-
-		XmlTest( "Entity transformation: read. ", expected, context, true );
-
-		FILE* textfile = fopen( "textfile.txt", "w" );
-		if ( textfile )
-		{
-			psg->Print( textfile, 0 );
-			fclose( textfile );
-		}
-		textfile = fopen( "textfile.txt", "r" );
-		assert( textfile );
-		if ( textfile )
-		{
-			char buf[ 1024 ];
-			fgets( buf, 1024, textfile );
-			XmlTest( "Entity transformation: write. ",
-					 "<psg context=\'Line 5 has &quot;quotation marks&quot; and &apos;apostrophe marks&apos;."
-					 " It also has &lt;, &gt;, and &amp;, as well as a fake copyright \xC2\xA9.' />",
-					 buf,
-					 true );
-		}
-		fclose( textfile );
-	}
-
-    {
-		FILE* textfile = fopen( "test5.xml", "w" );
-		if ( textfile )
-		{
-            fputs("<?xml version='1.0'?><a.elem xmi.version='2.0'/>", textfile);
-            fclose(textfile);
-
-			TiXmlDocument doc;
-            doc.LoadFile( "test5.xml" );
-            XmlTest( "dot in element attributes and names", doc.Error(), 0);
-		}
-    }
-
-	{
-		FILE* textfile = fopen( "test6.xml", "w" );
-		if ( textfile )
-		{
-            fputs("<element><Name>1.1 Start easy ignore fin thickness&#xA;</Name></element>", textfile );
-            fclose(textfile);
-
-            TiXmlDocument doc;
-            bool result = doc.LoadFile( "test6.xml" );
-            XmlTest( "Entity with one digit.", result, true );
-
-			TiXmlText* text = doc.FirstChildElement()->FirstChildElement()->FirstChild()->ToText();
-			XmlTest( "Entity with one digit.",
-						text->Value(), "1.1 Start easy ignore fin thickness\n" );
-		}
-    }
-
-	{
-		// DOCTYPE not preserved (950171)
-		// 
-		const char* doctype =
-			"<?xml version=\"1.0\" ?>"
-			"<!DOCTYPE PLAY SYSTEM 'play.dtd'>"
-			"<!ELEMENT title (#PCDATA)>"
-			"<!ELEMENT books (title,authors)>"
-			"<element />";
-
-		TiXmlDocument doc;
-		doc.Parse( doctype );
-		doc.SaveFile( "test7.xml" );
-		doc.Clear();
-		doc.LoadFile( "test7.xml" );
-		
-		TiXmlHandle docH( &doc );
-		TiXmlUnknown* unknown = docH.Child( 1 ).Unknown();
-		XmlTest( "Correct value of unknown.", "!DOCTYPE PLAY SYSTEM 'play.dtd'", unknown->Value() );
-		#ifdef TIXML_USE_STL
-		TiXmlNode* node = docH.Child( 2 ).Node();
-		std::string str;
-		str << (*node);
-		XmlTest( "Correct streaming of unknown.", "<!ELEMENT title (#PCDATA)>", str.c_str() );
-		#endif
-	}
-
-	{
-		// [ 791411 ] Formatting bug
-		// Comments do not stream out correctly.
-		const char* doctype = 
-			"<!-- Somewhat<evil> -->";
-		TiXmlDocument doc;
-		doc.Parse( doctype );
-
-		TiXmlHandle docH( &doc );
-		TiXmlComment* comment = docH.Child( 0 ).Node()->ToComment();
-
-		XmlTest( "Comment formatting.", " Somewhat<evil> ", comment->Value() );
-		#ifdef TIXML_USE_STL
-		std::string str;
-		str << (*comment);
-		XmlTest( "Comment streaming.", "<!-- Somewhat<evil> -->", str.c_str() );
-		#endif
-	}
-
-	{
-		// [ 870502 ] White space issues
-		TiXmlDocument doc;
-		TiXmlText* text;
-		TiXmlHandle docH( &doc );
-	
-		const char* doctype0 = "<element> This has leading and trailing space </element>";
-		const char* doctype1 = "<element>This has  internal space</element>";
-		const char* doctype2 = "<element> This has leading, trailing, and  internal space </element>";
-
-		TiXmlBase::SetCondenseWhiteSpace( false );
-		doc.Clear();
-		doc.Parse( doctype0 );
-		text = docH.FirstChildElement( "element" ).Child( 0 ).Text();
-		XmlTest( "White space kept.", " This has leading and trailing space ", text->Value() );
-
-		doc.Clear();
-		doc.Parse( doctype1 );
-		text = docH.FirstChildElement( "element" ).Child( 0 ).Text();
-		XmlTest( "White space kept.", "This has  internal space", text->Value() );
-
-		doc.Clear();
-		doc.Parse( doctype2 );
-		text = docH.FirstChildElement( "element" ).Child( 0 ).Text();
-		XmlTest( "White space kept.", " This has leading, trailing, and  internal space ", text->Value() );
-
-		TiXmlBase::SetCondenseWhiteSpace( true );
-		doc.Clear();
-		doc.Parse( doctype0 );
-		text = docH.FirstChildElement( "element" ).Child( 0 ).Text();
-		XmlTest( "White space condensed.", "This has leading and trailing space", text->Value() );
-
-		doc.Clear();
-		doc.Parse( doctype1 );
-		text = docH.FirstChildElement( "element" ).Child( 0 ).Text();
-		XmlTest( "White space condensed.", "This has internal space", text->Value() );
-
-		doc.Clear();
-		doc.Parse( doctype2 );
-		text = docH.FirstChildElement( "element" ).Child( 0 ).Text();
-		XmlTest( "White space condensed.", "This has leading, trailing, and internal space", text->Value() );
-	}
-
-	{
-		// Double attributes
-		const char* doctype = "<element attr='red' attr='blue' />";
-
-		TiXmlDocument doc;
-		doc.Parse( doctype );
-		
-		XmlTest( "Parsing repeated attributes.", 0, (int)doc.Error() );	// not an  error to tinyxml
-		XmlTest( "Parsing repeated attributes.", "blue", doc.FirstChildElement( "element" )->Attribute( "attr" ) );
-	}
-
-	{
-		// Embedded null in stream.
-		const char* doctype = "<element att\0r='red' attr='blue' />";
-
-		TiXmlDocument doc;
-		doc.Parse( doctype );
-		XmlTest( "Embedded null throws error.", true, doc.Error() );
-
-		#ifdef TIXML_USE_STL
-		istringstream strm( doctype );
-		doc.Clear();
-		doc.ClearError();
-		strm >> doc;
-		XmlTest( "Embedded null throws error.", true, doc.Error() );
-		#endif
-	}
-
-    {
-            // Legacy mode test. (This test may only pass on a western system)
-            const char* str =
-                        "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"
-                        "<ä>"
-                        "CöntäntßäöüÄÖÜ"
-                        "</ä>";
-
-            TiXmlDocument doc;
-            doc.Parse( str );
-
-            TiXmlHandle docHandle( &doc );
-            TiXmlHandle aHandle = docHandle.FirstChildElement( "ä" );
-            TiXmlHandle tHandle = aHandle.Child( 0 );
-            assert( aHandle.Element() );
-            assert( tHandle.Text() );
-            XmlTest( "ISO-8859-1 Parsing.", "CöntäntßäöüÄÖÜ", tHandle.Text()->Value() );
-    }
-
-	{
-		// Empty documents should return TIXML_ERROR_PARSING_EMPTY, bug 1070717
-		const char* str = "    ";
-		TiXmlDocument doc;
-		doc.Parse( str );
-		XmlTest( "Empty document error TIXML_ERROR_DOCUMENT_EMPTY", TiXmlBase::TIXML_ERROR_DOCUMENT_EMPTY, doc.ErrorId() );
-	}
-	#ifndef TIXML_USE_STL
-	{
-		// String equality. [ 1006409 ] string operator==/!= no worky in all cases
-		TiXmlString temp;
-		XmlTest( "Empty tinyxml string compare equal", ( temp == "" ), true );
-
-		TiXmlString    foo;
-		TiXmlString    bar( "" );
-		XmlTest( "Empty tinyxml string compare equal", ( foo == bar ), true );
-	}
-
-	#endif
-	{
-		// Bug [ 1195696 ] from marlonism
-		TiXmlBase::SetCondenseWhiteSpace(false); 
-		TiXmlDocument xml; 
-		xml.Parse("<text><break/>This hangs</text>"); 
-		XmlTest( "Test safe error return.", xml.Error(), false );
-	}
-
-	{
-		// Bug [ 1243992 ] - another infinite loop
-		TiXmlDocument doc;
-		doc.SetCondenseWhiteSpace(false);
-		doc.Parse("<p><pb></pb>test</p>");
-	} 
-	{
-		// Low entities
-		TiXmlDocument xml;
-		xml.Parse( "<test>&#x0e;</test>" );
-		const char result[] = { 0x0e, 0 };
-		XmlTest( "Low entities.", xml.FirstChildElement()->GetText(), result );
-		xml.Print();
-	}
-	{
-		// Bug [ 1451649 ] Attribute values with trailing quotes not handled correctly
-		TiXmlDocument xml;
-		xml.Parse( "<foo attribute=bar\" />" );
-		XmlTest( "Throw error with bad end quotes.", xml.Error(), true );
-	}
-	#ifdef TIXML_USE_STL
-	{
-		// Bug [ 1449463 ] Consider generic query
-		TiXmlDocument xml;
-		xml.Parse( "<foo bar='3' barStr='a string'/>" );
-
-		TiXmlElement* ele = xml.FirstChildElement();
-		double d;
-		int i;
-		float f;
-		bool b;
-		//std::string str;
-
-		XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &d ), TIXML_SUCCESS );
-		XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &i ), TIXML_SUCCESS );
-		XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &f ), TIXML_SUCCESS );
-		XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &b ), TIXML_WRONG_TYPE );
-		XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "nobar", &b ), TIXML_NO_ATTRIBUTE );
-		//XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "barStr", &str ), TIXML_SUCCESS );
-
-		XmlTest( "QueryValueAttribute", (d==3.0), true );
-		XmlTest( "QueryValueAttribute", (i==3), true );
-		XmlTest( "QueryValueAttribute", (f==3.0f), true );
-		//XmlTest( "QueryValueAttribute", (str==std::string( "a string" )), true );
-	}
-	#endif
-
-	#ifdef TIXML_USE_STL
-	{
-		// [ 1505267 ] redundant malloc in TiXmlElement::Attribute
-		TiXmlDocument xml;
-		xml.Parse( "<foo bar='3' />" );
-		TiXmlElement* ele = xml.FirstChildElement();
-		double d;
-		int i;
-
-		std::string bar = "bar";
-
-		const std::string* atrrib = ele->Attribute( bar );
-		ele->Attribute( bar, &d );
-		ele->Attribute( bar, &i );
-
-		XmlTest( "Attribute", atrrib->empty(), false );
-		XmlTest( "Attribute", (d==3.0), true );
-		XmlTest( "Attribute", (i==3), true );
-	}
-	#endif
-
-	{
-		// [ 1356059 ] Allow TiXMLDocument to only be at the top level
-		TiXmlDocument xml, xml2;
-		xml.InsertEndChild( xml2 );
-		XmlTest( "Document only at top level.", xml.Error(), true );
-		XmlTest( "Document only at top level.", xml.ErrorId(), TiXmlBase::TIXML_ERROR_DOCUMENT_TOP_ONLY );
-	}
-
-	{
-		// [ 1663758 ] Failure to report error on bad XML
-		TiXmlDocument xml;
-		xml.Parse("<x>");
-		XmlTest("Missing end tag at end of input", xml.Error(), true);
-		xml.Parse("<x> ");
-		XmlTest("Missing end tag with trailing whitespace", xml.Error(), true);
-	} 
-
-	{
-		// [ 1635701 ] fail to parse files with a tag separated into two lines
-		// I'm not sure this is a bug. Marked 'pending' for feedback.
-		TiXmlDocument xml;
-		xml.Parse( "<title><p>text</p\n><title>" );
-		//xml.Print();
-		//XmlTest( "Tag split by newline", xml.Error(), false );
-	}
-
-	#ifdef TIXML_USE_STL
-	{
-		// [ 1475201 ] TinyXML parses entities in comments
-		TiXmlDocument xml;
-		istringstream parse1( "<!-- declarations for <head> & <body> -->"
-						      "<!-- far &amp; away -->" );
-		parse1 >> xml;
-
-		TiXmlNode* e0 = xml.FirstChild();
-		TiXmlNode* e1 = e0->NextSibling();
-		TiXmlComment* c0 = e0->ToComment();
-		TiXmlComment* c1 = e1->ToComment();
-
-		XmlTest( "Comments ignore entities.", " declarations for <head> & <body> ", c0->Value(), true );
-		XmlTest( "Comments ignore entities.", " far &amp; away ", c1->Value(), true );
-	}
-	#endif
-
-	{
-		// [ 1475201 ] TinyXML parses entities in comments
-		TiXmlDocument xml;
-		xml.Parse("<!-- declarations for <head> & <body> -->"
-				  "<!-- far &amp; away -->" );
-
-		TiXmlNode* e0 = xml.FirstChild();
-		TiXmlNode* e1 = e0->NextSibling();
-		TiXmlComment* c0 = e0->ToComment();
-		TiXmlComment* c1 = e1->ToComment();
-
-		XmlTest( "Comments ignore entities.", " declarations for <head> & <body> ", c0->Value(), true );
-		XmlTest( "Comments ignore entities.", " far &amp; away ", c1->Value(), true );
-	}
-	/*
-	{
-		TiXmlDocument xml;
-		xml.Parse( "<tag>/</tag>" );
-		xml.Print();
-		xml.FirstChild()->Print( stdout, 0 );
-		xml.FirstChild()->Type();
-	}
-	*/
-	
-	/*  1417717 experiment
-	{
-		TiXmlDocument xml;
-		xml.Parse("<text>Dan & Tracie</text>");
-		xml.Print(stdout);
-	}
-	{
-		TiXmlDocument xml;
-		xml.Parse("<text>Dan &foo; Tracie</text>");
-		xml.Print(stdout);
-	}
-	*/
-	#if defined( WIN32 ) && defined( TUNE )
-	_CrtMemCheckpoint( &endMemState );
-	//_CrtMemDumpStatistics( &endMemState );
-
-	_CrtMemState diffMemState;
-	_CrtMemDifference( &diffMemState, &startMemState, &endMemState );
-	_CrtMemDumpStatistics( &diffMemState );
-	#endif
-
-	Logger::log ("\nPass %d, Fail %d\n", gPass, gFail);
-	return gFail;
-}
-
-

+ 0 - 121
Modules/Contents/2D Physics/Include/PolyPhysicsScreen.h

@@ -1,121 +0,0 @@
-/*
- *  PolyPhysicsScreen.h
- *  Poly
- *
- *  Created by Ivan Safrin on 5/8/08.
- *  Copyright 2008 __MyCompanyName__. All rights reserved.
- *
- */
-
-// @package ScreenPhysics
-
-#pragma once
-#include "PolyGlobals.h"
-#include "PolyScreen.h"
-#include "Box2D.h"
-//#include "PolyCoreServices.h"
-#include "PolyScreenLine.h"
-#include "PolyPhysicsScreenEntity.h"
-#include "PolyTimer.h"
-#include <vector>
-
-#define MAX_B2DCONTACTPOINTS 2048
-
-namespace Polycode {
-	
-class _PolyExport PhysicsScreenEvent : public Event {
-	public:	
-		
-		PhysicsScreenEntity *entity1;	
-		PhysicsScreenEntity *entity2;	
-	
-		static const int EVENT_NEW_SHAPE_COLLISION = 0;
-		static const int EVENT_END_SHAPE_COLLISION = 1;
-		static const int EVENT_PERSIST_SHAPE_COLLISION = 2;	
-};		
-
-
-enum ContactState
-{
-	e_contactAdded = 0,
-	e_contactPersisted = 1,
-	e_contactRemoved = 2,
-};
-	
-struct ContactPoint
-{
-	b2Shape* shape1;
-	b2Shape* shape2;
-	b2Vec2 normal;
-	b2Vec2 position;
-	b2Vec2 velocity;
-	b2ContactID id;
-	ContactState state;
-};
-	
-	
-class _PolyExport PhysicsScreen : public Screen, b2ContactListener {
-
-public:
-	PhysicsScreen();
-	PhysicsScreen(float freq);
-	
-	PhysicsScreen(Vector2 physicsWorldLowerBound, Vector2 physicsWorldUpperBound);
-	~PhysicsScreen();
-	
-	void Update();
-	PhysicsScreenEntity *addPhysicsChild(ScreenEntity *newEntity, int entType, float friction, float density, float restitution = 0, bool isSensor = false);
-	void removePhysicsChild(PhysicsScreenEntity *entityToRemove);
-	
-	PhysicsScreenEntity *addCollisionChild(ScreenEntity *newEntity, int entType);
-	
-	void createDistanceJoint(ScreenEntity *ent1, ScreenEntity *ent2, bool collideConnected);
-	void createPrismaticJoint(ScreenEntity *ent1, ScreenEntity *ent2, bool collideConnected);
-	b2RevoluteJoint *createRevoluteJoint(ScreenEntity *ent1, ScreenEntity *ent2, float ax, float ay, bool enableLimit, float lowerLimit, float upperLimit, bool motorEnabled, float motorSpeed, float maxTorque);
-	b2MouseJoint *createMouseJoint(ScreenEntity *ent1, Vector2 *mp);
-	void applyForce(ScreenEntity *ent, float fx, float fy);
-	void applyImpulse(ScreenEntity *ent, float fx, float fy);
-	
-	PhysicsScreenEntity *getPhysicsEntityByShape(b2Shape *shape);
-	
-	void setVelocity(ScreenEntity *ent, float fx, float fy);	
-	void setVelocityX(ScreenEntity *ent, float fx);	
-	void setVelocityY(ScreenEntity *ent, float fy);	
-	
-	void Add(const b2ContactPoint* point);
-	void Persist(const b2ContactPoint* point);
-	void Remove(const b2ContactPoint* point);				
-	
-	void wakeUp(ScreenEntity *ent);
-	
-	void handleEvent(Event *event);
-	
-	Vector2 getEntityCollisionNormal(ScreenEntity *ent1, ScreenEntity *ent2);
-	
-	bool areEntitiesColliding(ScreenEntity *ent1, ScreenEntity *ent2);
-	ScreenEntity *getEntityAtPosition(float x, float y);
-	bool testEntityAtPosition(ScreenEntity *ent, float x, float y);
-	
-	void Shutdown();
-	
-	PhysicsScreenEntity *getPhysicsByScreenEntity(ScreenEntity *ent);
-	void destroyMouseJoint(b2MouseJoint *mJoint);
-
-
-protected:
-	
-	void init(Vector2 physicsWorldLowerBound, Vector2 physicsWorldUpperBound, float physicsTimeStep, int physicsIterations, Vector2 physicsGravity);
-
-	Timer *updateTimer;
-	vector <PhysicsScreenEntity*> physicsChildren;
-	
-	ContactPoint m_points[MAX_B2DCONTACTPOINTS];
-	int32 numContactPoints;
-	
-	b2World *world;
-	float32 timeStep;
-	int32 iterations;
-};
-
-
-}

+ 0 - 49
Modules/Contents/2D Physics/Include/PolyPhysicsScreenEntity.h

@@ -1,49 +0,0 @@
-/*
- *  PolyPhysicsScreenEntity.h
- *  Poly
- *
- *  Created by Ivan Safrin on 5/8/08.
- *  Copyright 2008 __MyCompanyName__. All rights reserved.
- *
- */
- 
-// @package ScreenPhysics
-
-#pragma once
-#include "PolyGlobals.h"
-#include "PolyScreenEntity.h"
-#include "Box2D.h"
-
-namespace Polycode {
-
-	class _PolyExport PhysicsScreenEntity {
-		public:
-			PhysicsScreenEntity(ScreenEntity *entity, b2World *world, int entType, float friction, float density, float restitution, bool isSensor);
-			~PhysicsScreenEntity();		
-			
-			ScreenEntity *getScreenEntity();
-			
-			void applyTorque(float torque);
-			void applyForce(Vector2 force);
-			
-			void Update();
-			
-			static const int ENTITY_RECT = 1;
-			static const int ENTITY_CIRCLE = 2;	
-			static const int ENTITY_STATICRECT = 3;
-		
-			b2Body* body;
-			b2BodyDef *bodyDef;
-			b2Shape *shape;
-			
-			bool collisionOnly;
-		
-		protected:
-		
-		Vector2 lastPosition;
-		float lastRotation;
-			
-		ScreenEntity *screenEntity;
-	};
-
-}

+ 0 - 405
Modules/Contents/2D Physics/Source/PolyPhysicsScreen.cpp

@@ -1,405 +0,0 @@
-/*
- *  PolyPhysicsScreen.cpp
- *  Poly
- *
- *  Created by Ivan Safrin on 5/8/08.
- *  Copyright 2008 __MyCompanyName__. All rights reserved.
- *
- */
-
-
-#include "PolyPhysicsScreen.h"
-
-using namespace Polycode;
-
-
-void PhysicsScreen::Add(const b2ContactPoint* point) {
-	if (numContactPoints == MAX_B2DCONTACTPOINTS) {
-		return;
-	}
-	
-	ContactPoint* cp = m_points + numContactPoints;
-	cp->shape1 = point->shape1;
-	cp->shape2 = point->shape2;
-	cp->position = point->position;
-	cp->normal = point->normal;
-	cp->id = point->id;
-	cp->state = e_contactAdded;
-	
-	++numContactPoints;
-}
-
-void PhysicsScreen::Persist(const b2ContactPoint* point) {
-	if (numContactPoints == MAX_B2DCONTACTPOINTS) {
-		return;
-	}
-	
-	ContactPoint* cp = m_points + numContactPoints;
-	cp->shape1 = point->shape1;
-	cp->shape2 = point->shape2;
-	cp->position = point->position;
-	cp->normal = point->normal;
-	cp->id = point->id;
-	cp->state = e_contactPersisted;
-	
-	++numContactPoints;
-}
-
-void PhysicsScreen::Remove(const b2ContactPoint* point) {
-	if (numContactPoints == MAX_B2DCONTACTPOINTS) {
-		return;
-	}
-	
-	ContactPoint* cp = m_points + numContactPoints;
-	cp->shape1 = point->shape1;
-	cp->shape2 = point->shape2;
-	cp->position = point->position;
-	cp->normal = point->normal;
-	cp->id = point->id;
-	cp->state = e_contactRemoved;
-	
-	++numContactPoints;
-}
-
-PhysicsScreen::PhysicsScreen() : Screen() {
-	init(Vector2(-200.0f, -100.0f),Vector2(8500.0f, 1000.0f),1.0f/60.0f,10,Vector2(0.0f, 10.0f));
-}
-
-PhysicsScreen::PhysicsScreen(float freq) : Screen() {
-	init(Vector2(-200.0f, -100.0f),Vector2(8500.0f, 1000.0f),1.0f/freq,10,Vector2(0.0f, 10.0f));	
-}
-
-PhysicsScreen::PhysicsScreen(Vector2 physicsWorldLowerBound, Vector2 physicsWorldUpperBound)
-{
-	init(physicsWorldLowerBound,physicsWorldUpperBound,1.0f/60.0f,10,Vector2(0.0f, 10.0f));
-}
-
-void PhysicsScreen::init(Vector2 physicsWorldLowerBound, Vector2 physicsWorldUpperBound, float physicsTimeStep, int physicsIterations, Vector2 physicsGravity) {
-	numContactPoints = 0;	
-	timeStep = physicsTimeStep;
-	iterations = physicsIterations;
-	
-	b2AABB worldAABB;
-	worldAABB.lowerBound.Set(physicsWorldLowerBound.x/10.0,physicsWorldLowerBound.y/10.0);
-	worldAABB.upperBound.Set(physicsWorldUpperBound.x/10.0,physicsWorldUpperBound.y/10.0);
-	
-	b2Vec2 gravity(physicsGravity.x,physicsGravity.y);
-	bool doSleep = true;
-	world  = new b2World(worldAABB, gravity, doSleep);
-	
-	world->SetContactListener(this);
-
-	updateTimer = new Timer(true, 3);
-	updateTimer->addEventListener(this, Timer::EVENT_TRIGGER);
-}
-
-PhysicsScreenEntity *PhysicsScreen::getPhysicsByScreenEntity(ScreenEntity *ent) {
-	for(int i=0; i<physicsChildren.size();i++) {
-		if(physicsChildren[i]->getScreenEntity() == ent)
-			return physicsChildren[i];
-	}	
-	return NULL;
-}
-
-b2RevoluteJoint *PhysicsScreen::createRevoluteJoint(ScreenEntity *ent1, ScreenEntity *ent2, float ax, float ay, bool enableLimit, float lowerLimit, float upperLimit, bool motorEnabled, float motorSpeed, float maxTorque) {
-	PhysicsScreenEntity *pEnt1 = getPhysicsByScreenEntity(ent1);
-	PhysicsScreenEntity *pEnt2 = getPhysicsByScreenEntity(ent2);
-	if(pEnt1 == NULL || pEnt2 == NULL)
-		return NULL;
-	
-	b2Vec2 anchor((ent1->getPosition()->x+ax)/10.0f, (ent1->getPosition()->y+ay)/10.0f);
-	b2RevoluteJointDef *jointDef = new b2RevoluteJointDef();
-	jointDef->collideConnected = false;
-	jointDef->lowerAngle = lowerLimit * (PI/180.0f);
-	jointDef->upperAngle = upperLimit * (PI/180.0f);
-	jointDef->enableLimit = enableLimit;
-	jointDef->motorSpeed = motorSpeed;
-	jointDef->maxMotorTorque = maxTorque;
-	jointDef->enableMotor = motorEnabled;	
-	jointDef->Initialize(pEnt1->body, pEnt2->body, anchor);
-	b2RevoluteJoint *joint = (b2RevoluteJoint*)world->CreateJoint(jointDef);
-	return joint;
-}
-
-void PhysicsScreen::createPrismaticJoint(ScreenEntity *ent1, ScreenEntity *ent2, bool collideConnected) {
-
-}
-
-void PhysicsScreen::wakeUp(ScreenEntity *ent) {
-	PhysicsScreenEntity *pEnt = getPhysicsByScreenEntity(ent);
-	if(pEnt == NULL)
-		return;
-		
-	pEnt->body->WakeUp();
-}
-
-void PhysicsScreen::setVelocity(ScreenEntity *ent, float fx, float fy) {
-	PhysicsScreenEntity *pEnt = getPhysicsByScreenEntity(ent);
-	if(pEnt == NULL)
-		return;
-	
-	pEnt->body->WakeUp();
-	b2Vec2 f = pEnt->body->GetLinearVelocity();
-	if(fx != 0)
-		f.x = fx;
-	if(fy != 0)
-		f.y = fy;
-	
-	pEnt->body->SetLinearVelocity(f);
-}
-
-void PhysicsScreen::setVelocityX(ScreenEntity *ent, float fx) {
-	PhysicsScreenEntity *pEnt = getPhysicsByScreenEntity(ent);
-	if(pEnt == NULL)
-		return;
-	
-	pEnt->body->WakeUp();
-	b2Vec2 f = pEnt->body->GetLinearVelocity();
-	f.x = fx;	
-	pEnt->body->SetLinearVelocity(f);
-	
-}
-
-void PhysicsScreen::setVelocityY(ScreenEntity *ent, float fy) {
-	PhysicsScreenEntity *pEnt = getPhysicsByScreenEntity(ent);
-	if(pEnt == NULL)
-		return;
-	
-	pEnt->body->WakeUp();
-	b2Vec2 f = pEnt->body->GetLinearVelocity();
-	f.y = fy;	
-	pEnt->body->SetLinearVelocity(f);	
-}
-
-
-PhysicsScreenEntity *PhysicsScreen::addCollisionChild(ScreenEntity *newEntity, int entType) {
-	PhysicsScreenEntity *ret;
-	ret = addPhysicsChild(newEntity, entType, 0,0.1,0, true);
-	ret->collisionOnly = true; 
-	return ret;
-}
-
-void PhysicsScreen::applyForce(ScreenEntity *ent, float fx, float fy) {
-	PhysicsScreenEntity *pEnt = getPhysicsByScreenEntity(ent);
-	if(pEnt == NULL)
-		return;
-
-	pEnt->body->WakeUp();
-	b2Vec2 f =  b2Vec2(fx,fy);
-	b2Vec2 p = pEnt->body->GetWorldPoint(b2Vec2(0.0f, 0.0f));
-		
-	pEnt->body->ApplyForce(f, p);
-}
-
-void PhysicsScreen::applyImpulse(ScreenEntity *ent, float fx, float fy) {
-	PhysicsScreenEntity *pEnt = getPhysicsByScreenEntity(ent);
-	if(pEnt == NULL)
-		return;
-	
-	pEnt->body->WakeUp();
-	b2Vec2 f =  b2Vec2(fx,fy);
-	b2Vec2 p = pEnt->body->GetWorldPoint(b2Vec2(0.0f, 0.0f));
-	
-	pEnt->body->ApplyImpulse(f, p);	
-}
-
-
-
-void PhysicsScreen::createDistanceJoint(ScreenEntity *ent1, ScreenEntity *ent2, bool collideConnected) {
-	PhysicsScreenEntity *pEnt1 = getPhysicsByScreenEntity(ent1);
-	PhysicsScreenEntity *pEnt2 = getPhysicsByScreenEntity(ent2);
-	if(pEnt1 == NULL || pEnt2 == NULL)
-		return;
-	
-	b2Vec2 a1(ent1->getPosition()->x/10.0f, ent1->getPosition()->y/10.0f);
-	b2Vec2 a2(ent2->getPosition()->x/10.0f, ent2->getPosition()->y/10.0f);
-	b2DistanceJointDef *jointDef = new b2DistanceJointDef();
-	jointDef->Initialize(pEnt1->body, pEnt2->body, a1, a2);
-	jointDef->collideConnected = collideConnected;
-	world->CreateJoint(jointDef);
-}
-
-b2MouseJoint *PhysicsScreen::createMouseJoint(ScreenEntity *ent1, Vector2 *mp) {
-	
-	PhysicsScreenEntity *pEnt1 = getPhysicsByScreenEntity(ent1);
-	if(pEnt1 == NULL)
-		return NULL;
-
-	b2MouseJointDef *mj = new b2MouseJointDef();
-	
-	mj->body1 = world->GetGroundBody();
-	mj->body2 = pEnt1->body;
-	b2Vec2 mpos(mp->x/10.0f, mp->y/10.0f);
-	mj->target = mpos;
-#ifdef TARGET_FLOAT32_IS_FIXED
-	mj->maxForce = (pEnt1->body->GetMass() < 16.0)? (1000.0f * pEnt1->body->GetMass()) : float32(16000.0);
-#else
-	mj->maxForce = 1000.0f * pEnt1->body->GetMass();
-#endif
-	b2MouseJoint *m_mouseJoint = (b2MouseJoint*)world->CreateJoint(mj);
-	pEnt1->body->WakeUp();
-	Logger::log("OK %d!\n", m_mouseJoint);
-	return m_mouseJoint;
-}
-
-Vector2 PhysicsScreen::getEntityCollisionNormal(ScreenEntity *ent1, ScreenEntity *ent2) {
-	PhysicsScreenEntity *pEnt1 = getPhysicsByScreenEntity(ent1);
-	PhysicsScreenEntity *pEnt2 = getPhysicsByScreenEntity(ent2);	
-	if(pEnt1 == NULL || pEnt2 == NULL)
-		return Vector2(0,0);	
-	
-	PhysicsScreenEntity *rEnt1;
-	PhysicsScreenEntity *rEnt2;
-	for (int32 i = 0; i < numContactPoints; ++i)
-	{
-		ContactPoint* point = m_points + i;		
-		if (point->state == 0 || point->state == 1) {	
-			rEnt1= getPhysicsEntityByShape(point->shape1);
-			rEnt2 = getPhysicsEntityByShape(point->shape2);						
-			if((rEnt1 == pEnt1 && rEnt2 == pEnt2) || 
-			   (rEnt1 == pEnt2 && rEnt2 == pEnt1)) {
-				return Vector2(point->normal.x,point->normal.y);
-			}
-		}
-	}
-	return Vector2(0,0);	
-}
-
-bool PhysicsScreen::areEntitiesColliding(ScreenEntity *ent1, ScreenEntity *ent2) {
-	PhysicsScreenEntity *pEnt1 = getPhysicsByScreenEntity(ent1);
-	PhysicsScreenEntity *pEnt2 = getPhysicsByScreenEntity(ent2);	
-	if(pEnt1 == NULL || pEnt2 == NULL)
-		return false;
-	
-	PhysicsScreenEntity *rEnt1;
-	PhysicsScreenEntity *rEnt2;
-	for (int32 i = 0; i < numContactPoints; ++i)
-	{
-		ContactPoint* point = m_points + i;		
-		if (point->state == 0 || point->state == 1) {	
-			rEnt1= getPhysicsEntityByShape(point->shape1);
-			rEnt2 = getPhysicsEntityByShape(point->shape2);						
-			if((rEnt1 == pEnt1 && rEnt2 == pEnt2) || 
-			   (rEnt1 == pEnt2 && rEnt2 == pEnt1)) {
-				return true;
-			}
-		}
-	}
-	return false;
-}
-
-ScreenEntity *PhysicsScreen::getEntityAtPosition(float x, float y) {
-	ScreenEntity *ret = NULL;
-	
-	b2Vec2 mousePosition;
-	mousePosition.x = x/10.0f;
-	mousePosition.y = y/10.0f;
-	
-	for(int i=0;i<physicsChildren.size();i++) {
-		PhysicsScreenEntity *ent = physicsChildren[i];
-		if(ent->shape->TestPoint(ent->body->GetXForm(), mousePosition))
-			return ent->getScreenEntity();
-	}	
-	return ret;
-}
-
-bool PhysicsScreen::testEntityAtPosition(ScreenEntity *ent, float x, float y) {
-	PhysicsScreenEntity *pEnt = getPhysicsByScreenEntity(ent);	
-	
-	if(pEnt == NULL)
-		return false;
-	
-	b2Vec2 mousePosition;
-	mousePosition.x = x/10.0f;
-	mousePosition.y = y/10.0f;
-	
-	if(pEnt->shape->TestPoint(pEnt->body->GetXForm(), mousePosition))
-		return true;
-	else
-		return false;
-	
-}
-
-void PhysicsScreen::destroyMouseJoint(b2MouseJoint *mJoint) {
-		world->DestroyJoint(mJoint);
-		mJoint = NULL;
-}
-
-PhysicsScreenEntity *PhysicsScreen::addPhysicsChild(ScreenEntity *newEntity, int entType, float friction, float density, float restitution, bool isSensor) {
-	addChild(newEntity);
-	newEntity->setPositionMode(ScreenEntity::POSITION_CENTER);
-	PhysicsScreenEntity *newPhysicsEntity = new PhysicsScreenEntity(newEntity, world, entType, friction, density, restitution, isSensor);
-	physicsChildren.push_back(newPhysicsEntity);
-	newPhysicsEntity->body->WakeUp();
-	return newPhysicsEntity;
-}
-
-void PhysicsScreen::removePhysicsChild(PhysicsScreenEntity *entityToRemove) {
-	world->DestroyBody(entityToRemove->body);
-	removeChild(entityToRemove->getScreenEntity());
-	for(int i=0;i<physicsChildren.size();i++) {
-		if(physicsChildren[i] == entityToRemove) {
-			physicsChildren.erase(physicsChildren.begin()+i);
-		}
-	}
-}
-
-
-void PhysicsScreen::Shutdown() {
-
-}
-
-PhysicsScreen::~PhysicsScreen() {
-	delete world;
-	for(int i=0; i<physicsChildren.size();i++) {
-			delete physicsChildren[i];
-	}
-}
-
-PhysicsScreenEntity *PhysicsScreen::getPhysicsEntityByShape(b2Shape *shape) {
-	for(int i=0; i < physicsChildren.size(); i++) {
-		if(physicsChildren[i]->shape == shape)
-			return physicsChildren[i];
-	}
-	return NULL;
-}
-	
-void PhysicsScreen::handleEvent(Event *event) {
-	
-	numContactPoints = 0;
-	
-	if(event->getDispatcher() == updateTimer) {		
-		world->Step(timeStep, iterations);
-	}
-	
-	for (int32 i = 0; i < numContactPoints; ++i)
-	{
-		ContactPoint* point = m_points + i;		
-		if (point->state == 0) {	
-			PhysicsScreenEvent *newEvent = new PhysicsScreenEvent();
-			newEvent->entity1 = getPhysicsEntityByShape(point->shape1);
-			newEvent->entity2 = getPhysicsEntityByShape(point->shape2);			
-	
-			dispatchEvent(newEvent, PhysicsScreenEvent::EVENT_NEW_SHAPE_COLLISION);
-		} else if (point->state == 1) {
-			// Persist
-//			DrawPoint(point->position, 5.0f, b2Color(0.3f, 0.3f, 0.95f));
-		} else {
-			// Remove
-//			DrawPoint(point->position, 10.0f, b2Color(0.95f, 0.3f, 0.3f));
-			dispatchEvent(new PhysicsScreenEvent(), PhysicsScreenEvent::EVENT_END_SHAPE_COLLISION);			
-		}
-	}
-	
-	Screen::handleEvent(event);
-}
-
-void PhysicsScreen::Update() {
-//	unsigned int elapsed = updateTimer->getTicks();	
-//	if(updateTimer->hasElapsed()) {
-//		world->Step(timeStep, iterations);
-		for(int i=0; i<physicsChildren.size();i++) {
-			physicsChildren[i]->Update();
-		}
-//	}
-}

+ 0 - 107
Modules/Contents/2D Physics/Source/PolyPhysicsScreenEntity.cpp

@@ -1,107 +0,0 @@
-/*
- *  PolyPhysicsScreenEntity.cpp
- *  Poly
- *
- *  Created by Ivan Safrin on 5/8/08.
- *  Copyright 2008 __MyCompanyName__. All rights reserved.
- *
- */
-
-#define PI 3.14159265
-
-#include "PolyPhysicsScreenEntity.h"
-
-using namespace Polycode;
-
-PhysicsScreenEntity::PhysicsScreenEntity(ScreenEntity *entity, b2World *world, int entType, float friction, float density, float restitution, bool isSensor) {
-	screenEntity = entity;
-	
-	bodyDef = new b2BodyDef();
-	bodyDef->position.Set(screenEntity->getPosition()->x/10.0f, screenEntity->getPosition()->y/10.0f);
-	bodyDef->angle = screenEntity->getRotation()*(PI/180.0f);
-	body = world->CreateBody(bodyDef);
-	bodyDef->isBullet = isSensor;
-	
-	switch(entType) {
-		case ENTITY_STATICRECT:{
-			b2PolygonDef *groundShapeDef = new b2PolygonDef();
-			groundShapeDef->isSensor = isSensor;
-			groundShapeDef->SetAsBox(screenEntity->getWidth()/20.0f, screenEntity->getHeight()/20.0f);
-			shape = body->CreateShape(groundShapeDef);
-		}
-		break;
-		case ENTITY_RECT: {
-			b2PolygonDef *shapeDef;
-			shapeDef = new b2PolygonDef();
-			shapeDef->SetAsBox(screenEntity->getWidth()/20.0f, screenEntity->getHeight()/20.0f);
-			shapeDef->density = density;
-			shapeDef->friction = friction;
-			shapeDef->restitution = restitution;
-			shapeDef->isSensor = isSensor;			
-			shape = body->CreateShape(shapeDef);
-			}
-		break;			
-		case ENTITY_CIRCLE: {
-			b2CircleDef *shapeDef = new b2CircleDef();
-			shapeDef->radius = screenEntity->getWidth()/20.0f;
-			shapeDef->density = density;
-//			shapeDef->SetAsBox(screenEntity->getWidth()/20.0f, screenEntity->getHeight()/20.0f);
-			shapeDef->friction = friction;
-			shapeDef->restitution = restitution;
-			shapeDef->isSensor = isSensor;				
-			shape = body->CreateShape(shapeDef);
-			}
-		break;
-	}
-	
-	lastPosition.x = screenEntity->getPosition2D().x;
-	lastPosition.y = screenEntity->getPosition2D().y;
-
-	body->SetMassFromShapes();
-
-	collisionOnly = false;
-}
-
-void PhysicsScreenEntity::applyTorque(float torque) {
-	body->ApplyTorque(torque);
-}
-
-void PhysicsScreenEntity::applyForce(Vector2 force){
-	body->WakeUp();
-	body->ApplyForce(b2Vec2(force.x,force.y), b2Vec2(body->GetPosition().x,body->GetPosition().y));
-}
-
-ScreenEntity *PhysicsScreenEntity::getScreenEntity() {
-	return screenEntity;
-}
-			
-void PhysicsScreenEntity::Update() {
-	b2Vec2 position = body->GetPosition();
-	float32 angle = body->GetAngle();
-
-	if(lastRotation != screenEntity->getRotation() || collisionOnly) {
-		body->SetXForm(position, screenEntity->getRotation()*(PI/180.0f));		
-	} else {
-		screenEntity->setRotation(angle*(180.0f/PI));	
-	}
-	
-	if(lastPosition != screenEntity->getPosition2D() || collisionOnly) {
-		b2Vec2 newPos;
-		newPos.x = screenEntity->getPosition2D().x/10.0f; 
-		newPos.y = screenEntity->getPosition2D().y/10.0f;				
-		body->SetXForm(newPos, screenEntity->getRotation()*(PI/180.0f));
-		position.x = screenEntity->getPosition2D().x/10.0f; 
-		position.y = screenEntity->getPosition2D().y/10.0f; 				
-	} else {
-		screenEntity->setPosition(position.x*10.0f, position.y*10.0f);
-	}
-	
-	lastPosition.x = position.x*10.0f;
-	lastPosition.y = position.y*10.0f;	
-	
-	lastRotation = angle * (180.0f/PI);
-}
-
-PhysicsScreenEntity::~PhysicsScreenEntity() {
-
-}

+ 0 - 81
Modules/Contents/3D Physics/Include/PolyCollisionScene.h

@@ -1,81 +0,0 @@
-/*
- *  PolyCollisionScene.h
- *  Poly
- *
- *  Created by Ivan Safrin on 6/16/08.
- *  Copyright 2008 __MyCompanyName__. All rights reserved.
- *
- */
-
-// @package SceneDynamics
-
-#pragma once
-#include "PolyLogger.h"
-#include "PolyGlobals.h"
-#include "PolyGenericScene.h"
-#include "PolyCollisionSceneEntity.h"
-#include "btBulletCollisionCommon.h"
-#include "PolyVector3.h"
-#include <vector>
-
-using std::vector;
-
-namespace Polycode {
-
-struct CollisionResult {
-	bool collided;
-	Vector3 colNormal;
-	float colDist;
-	bool setOldPosition;
-	Vector3 newPos;
-};
-
-	struct RayTestResult {
-		SceneEntity *entity;
-		Vector3 normal;
-		Vector3 position;
-	};
-
-	class _PolyExport CollisionScene : public GenericScene {
-		public:
-			CollisionScene();
-			CollisionScene(bool virtualScene);		
-			~CollisionScene();
-		
-			void initCollisionScene();
-		
-			void Update();
-		
-			void enableCollision(SceneEntity *entity, bool val);
-		
-			CollisionSceneEntity *getCollisionEntityByObject(btCollisionObject *collisionObject);
-		
-			RayTestResult getFirstEntityInRay(const Vector3 &origin,  const Vector3 &dest);
-			
-			CollisionSceneEntity *getCollisionByScreenEntity(SceneEntity *ent);
-			CollisionResult testCollision(SceneEntity *ent1, SceneEntity *ent2);
-			CollisionResult testCollisionOnCollisionChild(CollisionSceneEntity *cEnt1, CollisionSceneEntity *cEnt2);
-				
-			CollisionResult testCollisionOnCollisionChild_Convex(CollisionSceneEntity *cEnt1, CollisionSceneEntity *cEnt2);
-		
-			CollisionResult testCollisionOnCollisionChild_RayTest(CollisionSceneEntity *cEnt1, CollisionSceneEntity *cEnt2);		
-			
-			Vector3 getCollisionNormalFromCollisionEnts(CollisionSceneEntity *cEnt1, CollisionSceneEntity *cEnt2);
-			
-			Vector3 getCollisionNormal(SceneEntity *ent1, SceneEntity *ent2);
-			
-			void applyVelocity(SceneEntity *entity, float x, float y, float z);
-			
-			void loadCollisionChild(SceneEntity *entity, bool autoCollide=false, int type=0);
-			void enableGravity(SceneEntity *entity);
-			
-			CollisionSceneEntity *addCollisionChild(SceneEntity *newEntity, bool autoCollide=false, int type=0);
-			CollisionSceneEntity *trackCollision(SceneEntity *newEntity, bool autoCollide, int type=0);
-			void adjustForCollision(CollisionSceneEntity *collisionEntity);
-		private:
-		
-			vector<CollisionSceneEntity*> collisionChildren;
-			btCollisionWorld *world;
-	};
-
-}

+ 0 - 57
Modules/Contents/3D Physics/Include/PolyCollisionSceneEntity.h

@@ -1,57 +0,0 @@
-/*
- *  PolyCollisionSceneEntity.h
- *  Poly
- *
- *  Created by Ivan Safrin on 6/17/08.
- *  Copyright 2008 __MyCompanyName__. All rights reserved.
- *
- */
-// @package SceneDynamics
-
-#pragma once
-#include "PolyLogger.h"
-#include "PolyGlobals.h"
-#include "PolySceneEntity.h"
-#include "btBulletCollisionCommon.h"
-#include "PolyCoreServices.h"
-#include "PolyTerrain.h"
-
-namespace Polycode {
-
-	class _PolyExport CollisionSceneEntity {
-		public:
-			CollisionSceneEntity(SceneEntity *entity, bool autoCollide, int type);
-			~CollisionSceneEntity();
-			
-			SceneEntity *getSceneEntity();
-			void Update();
-		
-			int getType() { return type; }
-			btConvexShape *getShape(){ return shape; }
-		
-			btCollisionObject *collisionObject;
-			bool gravityEnabled;
-			bool autoCollide;
-			Vector3 gravityVector;
-			Vector3 gVelocity;
-			float gravityStrength;
-		
-			Vector3 lastPosition;
-		
-			static const int SHAPE_BOX = 0;
-			static const int SHAPE_TERRAIN = 1;
-			static const int SHAPE_SPHERE = 2;	
-			static const int SHAPE_MESH = 3;			
-		
-			bool enabled;
-		
-		private:
-		
-			
-			btConvexShape *shape;
-		
-			int type;
-			SceneEntity *sceneEntity;
-	
-	};
-}

+ 0 - 335
Modules/Contents/3D Physics/Source/PolyCollisionScene.cpp

@@ -1,335 +0,0 @@
-/*
- *  PolyCollisionScene.cpp
- *  Poly
- *
- *  Created by Ivan Safrin on 6/16/08.
- *  Copyright 2008 __MyCompanyName__. All rights reserved.
- *
- */
-
-
-#include "PolyCollisionScene.h"
-
-using namespace Polycode;
-
-CollisionScene::CollisionScene() : GenericScene() {
-	initCollisionScene();
-}
-
-CollisionScene::CollisionScene(bool virtualScene) : GenericScene(virtualScene) { 
-	initCollisionScene();
-}
-
-void CollisionScene::initCollisionScene() {
-	
-	btVector3	worldAabbMin(-1000,-1000,-1000);
-	btVector3	worldAabbMax(1000,1000,1000);
-	
-	btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
-	btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);
-	//	dispatcher->setNearCallback(customNearCallback);
-	btAxisSweep3*	broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax);
-	world = new btCollisionWorld(dispatcher,broadphase,collisionConfiguration);	
-}
-
-void CollisionScene::Update() {
-	
-	for(int i=0; i < collisionChildren.size(); i++) {
-		if(collisionChildren[i]->enabled)
-			collisionChildren[i]->Update();
-	}
-	
-	world->performDiscreteCollisionDetection();	
-	for(int i=0; i < collisionChildren.size(); i++) {
-		if(collisionChildren[i]->enabled) {		
-			if(collisionChildren[i]->autoCollide) {
-				adjustForCollision(collisionChildren[i]);
-			}	
-		}
-	}
-	
-	for(int i=0; i < collisionChildren.size(); i++) {
-		if(collisionChildren[i]->enabled)		
-			collisionChildren[i]->lastPosition = *collisionChildren[i]->getSceneEntity()->getPosition();
-	}	
-}
-
-void CollisionScene::enableCollision(SceneEntity *entity, bool val) {
-	// what the fuck?? rename that
-	CollisionSceneEntity *cEnt = getCollisionByScreenEntity(entity);
-	if(cEnt) {
-		cEnt->enabled = val;
-	}
-}
-
-void CollisionScene::adjustForCollision(CollisionSceneEntity *collisionEntity) {
-	CollisionResult result;
-//	float elapsed = CoreServices::getInstance()->getCore()->getElapsed();
-	result.collided = false;
-	for(int i=0; i < collisionChildren.size(); i++) {
-		if(collisionChildren[i] != collisionEntity) {
-			result = testCollisionOnCollisionChild(collisionEntity, collisionChildren[i]);
-			if(result.collided) {
-				if(result.setOldPosition) {
-					collisionEntity->getSceneEntity()->setPosition(result.newPos);
-					collisionEntity->gVelocity.set(0,0,0);					
-				} else {
-//				printf("colnormal: %f %f %f %f\n", result.colNormal.x, result.colNormal.y, result.colNormal.z,result.colDist);
-				collisionEntity->getSceneEntity()->Translate(result.colNormal.x*result.colDist, result.colNormal.y*result.colDist, result.colNormal.z*result.colDist);
-//				Logger::log("colnormal: %f,%f,%f\n",result.colNormal.x,result.colNormal.y,result.colNormal.z);
-				if(result.colNormal.x > 0 && collisionEntity->gVelocity.x > 0)
-					collisionEntity->gVelocity.x = 0;
-				if(result.colNormal.x < 0 && collisionEntity->gVelocity.x < 0)
-					collisionEntity->gVelocity.x = 0;
-				if(result.colNormal.y > 0 && collisionEntity->gVelocity.y > 0)
-					collisionEntity->gVelocity.y = 0;
-				if(result.colNormal.y < 0 && collisionEntity->gVelocity.y < 0)
-					collisionEntity->gVelocity.y = 0;
-				if(result.colNormal.z > 0 && collisionEntity->gVelocity.z > 0)
-					collisionEntity->gVelocity.z = 0;
-				if(result.colNormal.z < 0 && collisionEntity->gVelocity.z < 0)
-					collisionEntity->gVelocity.z = 0;
-				collisionEntity->gVelocity.set(0,0,0);
-				}
-			}
-		}
-	}
-}	
-
-CollisionSceneEntity *CollisionScene::getCollisionByScreenEntity(SceneEntity *ent) {
-	for(int i=0; i<collisionChildren.size();i++) {
-		if(collisionChildren[i]->getSceneEntity() == ent)
-			return collisionChildren[i];
-	}	
-	return NULL;
-
-}
-
-void CollisionScene::applyVelocity(SceneEntity *entity, float x, float y, float z) {
-	CollisionSceneEntity *cEnt1 = getCollisionByScreenEntity(entity);
-	if(!cEnt1)
-		return;
-	cEnt1->gVelocity.x += x;
-	cEnt1->gVelocity.y += y;
-	cEnt1->gVelocity.z += z;	
-}
-
-Vector3 CollisionScene::getCollisionNormalFromCollisionEnts(CollisionSceneEntity *cEnt1, CollisionSceneEntity *cEnt2) {
-
-	int numManifolds = world->getDispatcher()->getNumManifolds();
-	for (int i=0;i<numManifolds;i++)
-	{
-		btPersistentManifold* contactManifold = world->getDispatcher()->getManifoldByIndexInternal(i);
-		btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
-		btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
- 		if((obA == cEnt1->collisionObject && obB == cEnt2->collisionObject) ||
-		 (obA == cEnt2->collisionObject && obB == cEnt1->collisionObject)) {
-			if(contactManifold->getNumContacts() > 0) {
-				btVector3 vec = contactManifold->getContactPoint(0).m_normalWorldOnB;
-				return Vector3(vec.getX(), vec.getY(), vec.getZ());
-			}
-		}
-	}
-	return Vector3(0,0,0);
-}
-
-Vector3 CollisionScene::getCollisionNormal(SceneEntity *ent1, SceneEntity *ent2) {
-	CollisionSceneEntity *cEnt1 = getCollisionByScreenEntity(ent1);
-	CollisionSceneEntity *cEnt2 = getCollisionByScreenEntity(ent2);
-	if(cEnt1 == NULL || cEnt2 == NULL)
-		return Vector3(0,0,0);
-
-	return getCollisionNormalFromCollisionEnts(cEnt1, cEnt2);
-}
-
-CollisionResult CollisionScene::testCollisionOnCollisionChild_Convex(CollisionSceneEntity *cEnt1, CollisionSceneEntity *cEnt2) {
-	CollisionResult result;
-	result.collided = false;
-	result.setOldPosition = false;
-	
-	Vector3 collNormal;
-	result.colNormal.set(0,0,0);									
-	result.colDist = 0; 	
-	
-	int numAdds = 0;
-	
-	int numManifolds = world->getDispatcher()->getNumManifolds();
-	for (int i=0;i<numManifolds;i++)
-	{
-		btPersistentManifold* contactManifold = world->getDispatcher()->getManifoldByIndexInternal(i);
-		btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
-		btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
- 		if((obA == cEnt1->collisionObject && obB == cEnt2->collisionObject) ||
-		   (obA == cEnt2->collisionObject && obB == cEnt1->collisionObject)) {
-//			contactManifold->refreshContactPoints(obA->getWorldTransform(), obB->getWorldTransform());
-			if(contactManifold->getNumContacts() > 0) {
-				for(int j=0; j < contactManifold->getNumContacts(); j++) {
-					if(contactManifold->getContactPoint(j).getDistance() <= btScalar(0.0)) {
-						btVector3 vec = contactManifold->getContactPoint(j).m_normalWorldOnB;
-						result.colNormal += Vector3(vec.getX(), vec.getY(), vec.getZ());	
-						result.colDist += contactManifold->getContactPoint(j).getDistance(); 
-						numAdds++;
-					}
-				}
-				
-				//				btVector3 vec = contactManifold->getContactPoint(0).m_normalWorldOnB;
-				//				result.colNormal.set(vec.getX(), vec.getY(), vec.getZ());
-				//				result.colDist = contactManifold->getContactPoint(0).getDistance(); 
-				
-				result.collided = true;
-				//				return result;
-			}
-		}
-	}
-	
-	if(numAdds > 0) {
-		result.colNormal = result.colNormal / (float)numAdds;
-		//		result.colNormal = Vector3(0,1,0);
-		//		result.colNormal.Normalize();
-		result.colDist  = result.colDist / (float)numAdds;
-	}
-	
-	return result;
-	//	return cEnt1->collisionObject->checkCollideWith(cEnt2->collisionObject);
-}
-
-RayTestResult CollisionScene::getFirstEntityInRay(const Vector3 &origin,  const Vector3 &dest) {
-
-	RayTestResult ret;
-	ret.entity = NULL;
-	
-	btVector3 fromVec(origin.x, origin.y, origin.z);
-	btVector3 toVec(dest.x, dest.y, dest.z);
-	
-	btCollisionWorld::ClosestRayResultCallback cb(fromVec, toVec);
-	world->rayTest (fromVec, toVec, cb);
-	
-	if (cb.HasHit ()) {
-		CollisionSceneEntity *retEnt = getCollisionEntityByObject(cb.m_collisionObject);
-		if(retEnt) {
-			ret.entity = retEnt->getSceneEntity();
-			ret.position = Vector3(cb.m_hitPointWorld.getX(), cb.m_hitPointWorld.getY(), cb.m_hitPointWorld.getZ());
-			ret.normal = Vector3(cb.m_hitNormalWorld.getX(), cb.m_hitNormalWorld.getY(), cb.m_hitNormalWorld.getZ());			
-			return ret;
-		}
-	}
-	
-	return ret;
-}
-
-CollisionSceneEntity *CollisionScene::getCollisionEntityByObject(btCollisionObject *collisionObject) {
-	for(int i=0; i <collisionChildren.size(); i++) {
-		if(collisionChildren[i]->collisionObject == collisionObject) {
-			return collisionChildren[i];
-		}
-	}
-	return NULL;
-}
-
-CollisionResult CollisionScene::testCollisionOnCollisionChild_RayTest(CollisionSceneEntity *cEnt1, CollisionSceneEntity *cEnt2) {
-	CollisionResult result;
-	result.collided = false;
-	result.setOldPosition = false;
-	btConvexShape *shape = cEnt1->getShape();
-	if(!shape)
-		return result;
-	
-//	shape->setMargin(1.0f);
-	
-	// hack to not collide with itself
-	world->removeCollisionObject(cEnt1->collisionObject);	
-
-	btVector3 fVec(cEnt1->lastPosition.x, cEnt1->lastPosition.y, cEnt1->lastPosition.z);
-	btVector3 toVec(cEnt1->getSceneEntity()->getPosition()->x, cEnt1->getSceneEntity()->getPosition()->y, cEnt1->getSceneEntity()->getPosition()->z);
-	
-	btCollisionWorld::ClosestConvexResultCallback cb(toVec, fVec);
-	btQuaternion qFrom;	
-	btQuaternion qTo;
-	qFrom.setRotation (btVector3(1.0, 0.0, 0.0), 0.0);
-	qTo.setRotation (btVector3(1.0, 0.0, 0.0), 0.0);
-	btTransform from(qFrom, fVec);
-	btTransform to(qTo, toVec);
-		
-	world->convexSweepTest(shape, from, to, cb);
-	
-	if (cb.HasHit()) {
-		result.collided = true;
-		
-		btVector3 newVec = toVec;
-		newVec.setInterpolate3(fVec, toVec, cb.m_closestHitFraction);		
-		result.colDist = newVec.distance(toVec);// + 0.001f;
-
-//		result.colDist = fVec.distance(toVec);// - cb.m_closestHitFraction;
-//		cb.m_hitPointWorld
-		
-//		result.colDist = shape->
-//		result.colDist = cb.m_hitPointWorld.distance(fVec) - shape->;
-
-		/*
-		btVector3 linVel, angVel;
-		btTransformUtil::calculateVelocity (from, to, 1.0, linVel, angVel);
-		btTransform T;
-		btTransformUtil::integrateTransform (from, linVel, angVel, cb.m_closestHitFraction, T);
-		btVector3 newVec;
-		newVec = T.getOrigin(); // * newVec;
-		result.colDist = toVec.distance(newVec);	
-		
-		Logger::log("dist: %f\n", result.colDist);
-		*/
-		
-//		result.colNormal = cEnt1->getSceneEntity()->getPosition()->(cEnt1->lastPosition);		
-		result.colNormal = Vector3(cb.m_hitNormalWorld.getX(), cb.m_hitNormalWorld.getY(), cb.m_hitNormalWorld.getZ());
-		result.colNormal.Normalize();
-	}
-	
-	world->addCollisionObject(cEnt1->collisionObject);
-	
-	return result;
-}
-
-CollisionResult CollisionScene::testCollisionOnCollisionChild(CollisionSceneEntity *cEnt1, CollisionSceneEntity *cEnt2) {
-	if(cEnt2->getType() == CollisionSceneEntity::SHAPE_TERRAIN || cEnt2->getType() == CollisionSceneEntity::SHAPE_MESH) {
-		return testCollisionOnCollisionChild_RayTest(cEnt1, cEnt2);		
-	} else {
-		return testCollisionOnCollisionChild_Convex(cEnt1, cEnt2);
-	}
-}
-
-CollisionResult CollisionScene::testCollision(SceneEntity *ent1, SceneEntity *ent2) {
-	CollisionSceneEntity *cEnt1 = getCollisionByScreenEntity(ent1);
-	CollisionSceneEntity *cEnt2 = getCollisionByScreenEntity(ent2);
-	CollisionResult result;
-	result.collided = false;
-	if(cEnt1 == NULL || cEnt2 == NULL)
-		return result;
-	return testCollisionOnCollisionChild(cEnt1, cEnt2);
-}
-
-CollisionScene::~CollisionScene() {
-
-}
-
-void CollisionScene::enableGravity(SceneEntity *entity) {
-	CollisionSceneEntity *cEnt1 = getCollisionByScreenEntity(entity);
-	if(!cEnt1)
-		return;
-	cEnt1->gravityEnabled = true;
-}
-
-void CollisionScene::loadCollisionChild(SceneEntity *entity, bool autoCollide, int type) {
-	addCollisionChild(entity, autoCollide, type);
-}
-
-CollisionSceneEntity *CollisionScene::trackCollision(SceneEntity *newEntity, bool autoCollide, int type) {
-	CollisionSceneEntity *newCollisionEntity = new CollisionSceneEntity(newEntity,autoCollide, type);
-	world->addCollisionObject(newCollisionEntity->collisionObject);
-	collisionChildren.push_back(newCollisionEntity);
-//	newCollisionEntity->Update();
-	return newCollisionEntity;
-}
-
-CollisionSceneEntity *CollisionScene::addCollisionChild(SceneEntity *newEntity, bool autoCollide, int type) {
-	addEntity(newEntity);
-	return trackCollision(newEntity, autoCollide, type);
-
-}

+ 0 - 124
Modules/Contents/3D Physics/Source/PolyCollisionSceneEntity.cpp

@@ -1,124 +0,0 @@
-/*
- *  PolyCollisionSceneEntity.cpp
- *  Poly
- *
- *  Created by Ivan Safrin on 6/17/08.
- *  Copyright 2008 __MyCompanyName__. All rights reserved.
- *
- */
-
-#include "PolyCollisionSceneEntity.h"
-
-using namespace Polycode;
-
-CollisionSceneEntity::CollisionSceneEntity(SceneEntity *entity, bool autoCollide, int type) {
-	gravityEnabled = false;
-	this->autoCollide = autoCollide;
-	sceneEntity = entity;
-	gravityVector.y = -1.0f;
-	
-	this->type = type;
-	enabled = true;
-	
-	gravityStrength = 5.0f;
-	
-	btMatrix3x3 basisA;
-	basisA.setIdentity();
-	collisionObject = new btCollisionObject();
-	collisionObject->getWorldTransform().setBasis(basisA);
-	
-	lastPosition = *entity->getPosition();
-	
-	shape = NULL;
-	
-	btBoxShape* box;
-	btSphereShape* sphere;	
-	SceneMesh *sceneMesh;
-
-	switch(type) {
-		case SHAPE_BOX:
-			box = new btBoxShape(btVector3(entity->bBox.x/2.0f, entity->bBox.y/2.0f,entity->bBox.z/2.0f));
-			collisionObject->setCollisionShape(box);
-			shape = box;
-		break;
-		case SHAPE_SPHERE:
-			sphere = new btSphereShape(entity->bBox.x/2.0f);
-			collisionObject->setCollisionShape(sphere);
-			shape = sphere;			
-		break;
-		case SHAPE_MESH:
-			sceneMesh = dynamic_cast<SceneMesh*>(entity);
-			if(sceneMesh != NULL) {
-				btTriangleMesh *btMesh = new btTriangleMesh();
-				for(int i=0; i < sceneMesh->getMesh()->getPolygonCount(); i++) {
-					Polygon *poly = sceneMesh->getMesh()->getPolygon(i);
-					btVector3 v0 = btVector3(btScalar(poly->getVertex(0)->x),btScalar(poly->getVertex(0)->y),btScalar(poly->getVertex(0)->z));
-					btVector3 v1= btVector3(btScalar(poly->getVertex(1)->x),btScalar(poly->getVertex(1)->y),btScalar(poly->getVertex(1)->z));
-					btVector3 v2= btVector3(btScalar(poly->getVertex(2)->x),btScalar(poly->getVertex(2)->y),btScalar(poly->getVertex(2)->z));					
-					btMesh->addTriangle(v2,v1,v0);
-				}
-				btBvhTriangleMeshShape *concaveShape = new btBvhTriangleMeshShape(btMesh, true);
-				collisionObject->setCollisionShape(concaveShape);
-			} else {
-				Logger::log("Tried to make a mesh collision object from a non-mesh\n");
-				box = new btBoxShape(btVector3(entity->bBox.x/2.0f, entity->bBox.y/2.0f,entity->bBox.z/2.0f));			
-				collisionObject->setCollisionShape(box);	
-				shape = box;				
-			}			
-		break;
-		case SHAPE_TERRAIN:			
-			Terrain *terrain = dynamic_cast<Terrain*>(entity);
-			if(terrain != NULL) {
-//				btHeightfieldTerrainShape *hf = new btHeightfieldTerrainShape(ter
-				btTriangleMesh *btMesh = new btTriangleMesh();
-				for(int i=0; i < terrain->getMesh()->getPolygonCount(); i++) {
-					Polygon *poly = terrain->getMesh()->getPolygon(i);
-					btVector3 v0 = btVector3(btScalar(poly->getVertex(0)->x),btScalar(poly->getVertex(0)->y),btScalar(poly->getVertex(0)->z));
-					btVector3 v1= btVector3(btScalar(poly->getVertex(1)->x),btScalar(poly->getVertex(1)->y),btScalar(poly->getVertex(1)->z));
-					btVector3 v2= btVector3(btScalar(poly->getVertex(2)->x),btScalar(poly->getVertex(2)->y),btScalar(poly->getVertex(2)->z));					
-					btMesh->addTriangle(v2,v1,v0);
-				}
-				btBvhTriangleMeshShape *concaveShape = new btBvhTriangleMeshShape(btMesh, true);
-				collisionObject->setCollisionShape(concaveShape);
-			} else {
-				Logger::log("Tried to make a terrain collision object from a non-terrain\n");
-				box = new btBoxShape(btVector3(entity->bBox.x/2.0f, entity->bBox.y/2.0f,entity->bBox.z/2.0f));			
-				collisionObject->setCollisionShape(box);	
-				shape = box;				
-			}
-		break;
-	}
-	gVelocity.set(0,0,0);
-}
-
-void CollisionSceneEntity::Update() {
-	
-//	lastPosition = *getSceneEntity()->getPosition();	
-	if(gravityEnabled) {	
-		float elapsed = CoreServices::getInstance()->getCore()->getElapsed();
-		Vector3 elapsedGrav = gravityVector;
-		elapsedGrav * elapsed * gravityStrength;
-		gVelocity = gVelocity+(elapsedGrav);
-		sceneEntity->Translate(gVelocity.x * elapsed, gVelocity.y * elapsed,gVelocity.z * elapsed);
-		sceneEntity->rebuildTransformMatrix();
-	}
-
-	btQuaternion orn;
-//	collisionObject->getCollisionShape()->setLocalScaling
-	collisionObject->getWorldTransform().setFromOpenGLMatrix(sceneEntity->getConcatenatedMatrix().ml);
-
-/*	
-	float rads = PI/180.0f;
-	orn.setEuler(sceneEntity->getCombinedYaw()*rads,sceneEntity->getCombinedPitch()*rads,sceneEntity->getCombinedRoll()*rads);
-	collisionObject->getWorldTransform().setRotation(orn);
-	collisionObject->getWorldTransform().setOrigin(btVector3(sceneEntity->getCombinedPosition().x, sceneEntity->getCombinedPosition().y, sceneEntity->getCombinedPosition().z));
-*/	
-}
-
-SceneEntity *CollisionSceneEntity::getSceneEntity() {
-	return sceneEntity;
-}
-
-CollisionSceneEntity::~CollisionSceneEntity() {
-
-}