[neveredit-commits] SF.net SVN: neveredit:[145] trunk/neveredit/ui/MapWindow.py
Status: Beta
Brought to you by:
sumpfork
From: <nin...@us...> - 2008-09-28 02:56:34
|
Revision: 145 http://neveredit.svn.sourceforge.net/neveredit/?rev=145&view=rev Author: niniendowarrior Date: 2008-09-28 02:56:27 +0000 (Sun, 28 Sep 2008) Log Message: ----------- Code attempts to address difficulty with Z-axis mouse over selection but this is really just a work around and should be eliminated when a proper fix is done. Do not think this is a permanent fix for the problem\! Modified Paths: -------------- trunk/neveredit/ui/MapWindow.py Modified: trunk/neveredit/ui/MapWindow.py =================================================================== --- trunk/neveredit/ui/MapWindow.py 2008-08-23 02:18:32 UTC (rev 144) +++ trunk/neveredit/ui/MapWindow.py 2008-09-28 02:56:27 UTC (rev 145) @@ -316,7 +316,7 @@ ray = self.rayToBasePlane(float(evt.GetX()), float(self.height-evt.GetY())) x,y = self.rayPointOnBasePlane(ray) - contents = self.getContentsForPoint(x,y)['things'] + contents = self.getContentsForPointWithRay(x,y,ray)['things'] closestIntersect = sys.maxint toHighlight = -1 for thing,id in contents: @@ -541,6 +541,85 @@ py = self.area.getHeight()*10.0 return px,py +# +# This proc is a hack and not a very good one at that. Sometimes it works, sometimes it doesn't. +# Either way, z-axis manipulation is not quite ready yet. +# + + def getContentsForPointWithRay(self,x,y,ray): + return self.getContentsForPointHelperWithRay(x,y,ray,self.quadTreeRoot) + +# +# This proc is a hack and not a very good one at that. Sometimes it works, sometimes it doesn't. +# Either way, z-axis manipulation is not quite ready yet. +# + + def getContentsForPointHelperWithRay(self,x,y,ray,node): + if not node.children: + return node.contents + else: + print "Children Testing: ",node.children + for row in node.children: + for c in row: + print "Testing for this: ",c + print "x point on baseplane: ",x + print "y point on baseplane: ",y + # might want to check for elevated stuff + # before we go to the standard z= 0 test. + + if not c.children: + print "passing contents ",c.contents + contents_thing = c.contents['things'] + for thing,id in contents_thing: + if thing.getModel(): + print "Object: ",thing + print "Objx: ",thing.getX() + print "Objy: ",thing.getY() + print "Objz: ",thing.getZ() + # Check if Z is 0... do standard check. + # if Z is not 0... adjust by deducting Y component by Z. (BAD HACK!) + + if thing.getZ() > 0: + #do bad hack. + print "Do bad hack" + z = thing.getZ() + # Bad hack applies to X or Y, try Y first. + origY = y + origX = x + y = y - z + if x >= c.xmin and x <= c.xmax and y >= c.ymin and y <= c.ymax: + print "This is good, but hacked to work. Pass this to ray trace." + return self.getContentsForPointHelperWithRay(x,y,ray,c) + else: + # We try X instead. + y = origY + x = x - z + if x >= c.xmin and x <= c.xmax and y >= c.ymin and y <= c.ymax: + print "This is good, but hacked to work. Pass this to ray trace." + return self.getContentsForPointHelperWithRay(x,y,ray,c) + + + #return node.contents + else: + #do standard check with base plane. + if x >= c.xmin and x <= c.xmax and y >= c.ymin and y <= c.ymax: + print "This is good. Pass this to ray trace." + return self.getContentsForPointHelperWithRay(x,y,ray,c) + + else: + print "stub print: ",thing + return self.getContentsForPointHelperWithRay(x,y,ray,c) + else: + #Let's do standard check. + #do standard check with base plane. + if x >= c.xmin and x <= c.xmax and y >= c.ymin and y <= c.ymax: + print "This is good. Pass this to ray trace." + return self.getContentsForPointHelperWithRay(x,y,ray,c) + + + return node.contents + + def getContentsForPoint(self,x,y): return self.getContentsForPointHelper(x,y,self.quadTreeRoot) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |