Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1352 - trunk/UserInterface


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1352 - trunk/UserInterface
  • Date: Thu, 19 Apr 2007 17:12:38 -0600 (MDT)

Author: bigler
Date: Thu Apr 19 17:12:37 2007
New Revision: 1352

Modified:
   trunk/UserInterface/XWindowUI.cc
   trunk/UserInterface/XWindowUI.h
Log:

UserInterface/XWindowUI.cc
UserInterface/XWindowUI.h

  Call MantaInterface::shootOneRay from within a transaction.  This
  fixes a bug I've been trying to track down since yesterday.

  Consolidate the mouse_debug_ray and mouse_debug_sse_ray into a
  single function that changes the number of debug rays based on the
  Shift/Control state.

  Added shootDebugRays function for the transaction.


Modified: trunk/UserInterface/XWindowUI.cc
==============================================================================
--- trunk/UserInterface/XWindowUI.cc    (original)
+++ trunk/UserInterface/XWindowUI.cc    Thu Apr 19 17:12:37 2007
@@ -542,7 +542,7 @@
                  Callback::create(this, &XWindowUI::mouse_debug_ray));
   register_mouse(ShiftMask, Button1,
                  "Debug SSE ray",
-                 Callback::create(this, &XWindowUI::mouse_debug_sse_ray));
+                 Callback::create(this, &XWindowUI::mouse_debug_ray));
 }
 
 void XWindowUI::helpkey(unsigned int, unsigned long, int)
@@ -807,68 +807,63 @@
   }
 }
 
-void XWindowUI::mouse_debug_ray(unsigned int, unsigned int,
-                                int event, int channel,
-                                int mouse_x, int mouse_y)
+void XWindowUI::shootDebugRays(int channel,
+                               int mouse_x, int mouse_y,
+                               int numPixels)
 {
-  if(event != ButtonPress) {
-    return;
-  }
   XWindow* window = windows[channel];
-  Real image_x = (2.0*mouse_x+1)/window->xres - 1.0;
-  Real image_y = 1.0 - (2.0*mouse_y+1)/window->yres;
-  //  std::cerr << "Debug ray at ("<<image_x<<", "<<image_y<<")\n";
   std::cerr << "Debug ray at ("<<mouse_x<<", "<<mouse_y<<")\n";
-
-  RayPacketData data;
-  RayPacket rays( data, RayPacket::UnknownShape, 0, 1, 0, 0 );
-
-  rays.setFlag( RayPacket::DebugPacket | RayPacket::ConstantEye);
-
-       // Shoot the ray.
-       Color color;
-       rtrt_interface->shootOneRay( color, rays, image_x, image_y, channel );
-
-  if (rays.wasHit(0)) {
-    std::cerr << "t:       " << rays.getMinT(0) << "\n";
-    std::cerr << "hit pos: " << rays.getHitPosition(0) << "\n";
-    std::cerr << "color  : " << rays.getColor(0).toString() << "\n";
-  }
-}
-
-void XWindowUI::mouse_debug_sse_ray(unsigned int, unsigned int,
-                                    int event, int channel,
-                                    int mouse_x, int mouse_y)
-{
-  if(event != ButtonPress) {
+  if (numPixels > RayPacket::MaxSize) {
+    std::cerr << "XWindowUI::shootDebugRays: numPixels("<<numPixels<<") > 
RayPacket::MaxSize("<<RayPacket::MaxSize<<")\n";
     return;
   }
-  XWindow* window = windows[channel];
-  RayPacketData data;
-  RayPacket rays( data, RayPacket::LinePacket, 0, 4, 0, 0 );
 
+  RayPacketData data;
+  RayPacket rays( data, RayPacket::LinePacket, 0, numPixels, 0, 0 );
+  
   Real image_x = (2.0*mouse_x+1)/window->xres - 1.0;
   Real image_y = 1.0 - (2.0*mouse_y+1)/window->yres;
-  for(int i = 0; i < 4; ++i) {
+  for(int i = 0; i < numPixels; ++i) {
     Real x = (2.0*mouse_x+i+1)/window->xres - 1.0;
     rays.setPixel(i, 0, x, image_y);
   }
-  //  std::cerr << "Debug ray at ("<<image_x<<", "<<image_y<<")\n";
-  std::cerr << "Debug sse ray at ("<<mouse_x<<", "<<mouse_y<<")\n";
 
+  // TODO(bigler): shouldn't ConstantEye be set in the camera?
   rays.setFlag( RayPacket::DebugPacket | RayPacket::ConstantEye );
 
-       // Shoot the ray.
+       // Shoot the rays.
        Color color;
        rtrt_interface->shootOneRay( color, rays, image_x, image_y, channel );
 
-  for(int i = 0; i < 4; ++i) {
+  for(int i = 0; i < numPixels; ++i) {
     if (rays.wasHit(i)) {
       std::cerr << "t("<<i<<"):       " << rays.getMinT(i) << "\n";
       std::cerr << "hit pos("<<i<<"): " << rays.getHitPosition(i) << "\n";
       std::cerr << "color  : "          << rays.getColor(i).toString() << 
"\n";
     }
   }
+  
+}
+
+void XWindowUI::mouse_debug_ray(unsigned int state, unsigned int,
+                                int event, int channel,
+                                int mouse_x, int mouse_y)
+{
+  if(event != ButtonPress) {
+    return;
+  }
+  int numPixels = 1;
+  if (state & ControlMask) {
+    numPixels = 1;
+  } else if (state & ShiftMask) {
+    numPixels = 4;
+  }
+  rtrt_interface->addTransaction("XWindowUI::shootDebugRays",
+                                 Callback::create(this,
+                                                  &XWindowUI::shootDebugRays,
+                                                  channel,
+                                                  mouse_x, mouse_y, 
numPixels)
+                                 );
 }
 
 void XWindowUI::handle_event(XEvent& e)

Modified: trunk/UserInterface/XWindowUI.h
==============================================================================
--- trunk/UserInterface/XWindowUI.h     (original)
+++ trunk/UserInterface/XWindowUI.h     Thu Apr 19 17:12:37 2007
@@ -52,6 +52,7 @@
     void removeConnection(int fd);
 
     typedef CallbackBase_3Data<unsigned int, unsigned long, int> 
KeyEventCallbackType;
+    // Args are (state, current_button, event, channel, mouse_x, mouse_y).
     typedef CallbackBase_6Data<unsigned int, unsigned int, int, int, int, 
int> MouseEventCallbackType;
 
     void register_key(unsigned int state, unsigned long key,
@@ -92,7 +93,8 @@
     void mouse_dolly(unsigned int, unsigned int, int, int, int, int);
     void mouse_rotate(unsigned int, unsigned int, int, int, int, int);
     void mouse_debug_ray(unsigned int, unsigned int, int, int, int, int);
-    void mouse_debug_sse_ray(unsigned int, unsigned int, int, int, int, int);
+    // Transaction function
+    void shootDebugRays(int channel, int mouse_x, int mouse_y, int 
numPixels);
 
     void animation_callback(int, int, bool&);
 




  • [MANTA] r1352 - trunk/UserInterface, bigler, 04/19/2007

Archive powered by MHonArc 2.6.16.

Top of page