Browse Source

Added grid snapping support for drag/drop object creation

Gyedo Jeon 15 years ago
parent
commit
36956aed7b
1 changed files with 5 additions and 0 deletions
  1. 5 0
      direct/src/leveleditor/LevelEditorUIBase.py

+ 5 - 0
direct/src/leveleditor/LevelEditorUIBase.py

@@ -79,6 +79,11 @@ class PandaTextDropTarget(wx.TextDropTarget):
             # create a temp nodePath to get the position
             # create a temp nodePath to get the position
             np = NodePath('temp')
             np = NodePath('temp')
             np.setPos(self.view.camera, hitPt)
             np.setPos(self.view.camera, hitPt)
+
+            if base.direct.manipulationControl.fGridSnap:
+                snappedPos = self.view.grid.computeSnapPoint(np.getPos())
+                np.setPos(snappedPos)
+            
             # update temp nodePath's HPR and scale with newobj's
             # update temp nodePath's HPR and scale with newobj's
             np.setHpr(newobj.getHpr())
             np.setHpr(newobj.getHpr())
             np.setScale(newobj.getScale())
             np.setScale(newobj.getScale())