changeset 17:131331ebb599

cpVect toString method and some cleanup
author Extrawurst
date Thu, 09 Dec 2010 01:51:30 +0100
parents af2f61a96318
children a376e5d3eb00
files trunk/chipmunkd/chipmunk_types.d trunk/chipmunkd/cpSpaceHash.d
diffstat 2 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/trunk/chipmunkd/chipmunk_types.d	Sat Dec 04 02:02:29 2010 +0100
+++ b/trunk/chipmunkd/chipmunk_types.d	Thu Dec 09 01:51:30 2010 +0100
@@ -3,6 +3,8 @@
 
 module chipmunkd.chipmunk_types;
 
+import std.string;
+
 //#ifdef __APPLE__
 //   #import "TargetConditionals.h"
 //#endif
@@ -100,7 +102,15 @@
 //	#import <CoreGraphics/CGGeometry.h>
 //	typedef CGPoint cpVect;
 //#else
-	struct cpVect{cpFloat x = 0; cpFloat y=0;}
+	struct cpVect
+	{
+		cpFloat x = 0; cpFloat y=0;
+		
+		string toString() const
+		{
+			return .format("(%s,%s)",x,y);
+		}
+	}
 //#endif
 
 alias uint cpHashValue;
--- a/trunk/chipmunkd/cpSpaceHash.d	Sat Dec 04 02:02:29 2010 +0100
+++ b/trunk/chipmunkd/cpSpaceHash.d	Thu Dec 09 01:51:30 2010 +0100
@@ -285,7 +285,7 @@
 static cpHashValue
 hash_func(cpHashValue x, cpHashValue y, cpHashValue n)
 {
-	return cast(cpHashValue)((x*1640531513uL ^ y*2654435789uL) % n);
+	return cast(cpHashValue)(( (x*1640531513uL) ^ (y*2654435789uL) ) % n);
 }
 
 // Much faster than (int)floor(f)