Re: [Flightgear-devel] Patch for 3d model_panel

2005-11-30 Thread Simon Hollier
> Simon Hollier wrote:
>
>>Hello,
>>
>>Attached is a patch for flightgear and simgear that removes the
>>model_panel kludge and fixes a potential memory leak.
>>
>>Thoughts/comments?
>>
>>Simon
>>
>>
> I can not test the patch due to lack of time, but I have the impression
> that this is not backward
> compatible with the current code, ie since the panel is inserted in the
> scene graph *after*
> animations reading you can no more have animations on panels.
>
> Harald.

Hi Harald,

Thanks for the response.

AFAIKT, the purpose of the panel is to draw textured backgrounds, hot
spots, and receive mouse events.  They're used with the 3D models to
define hotspots for the buttons, switches, etc...  Animations pertain to
the actual AC3D model and it's various xml files or at least not to the
panel.

Simon


___
Flightgear-devel mailing list
Flightgear-devel@flightgear.org
http://mail.flightgear.org/mailman/listinfo/flightgear-devel
2f585eeea02e2c79d7b1d8c4963bae2d


Re: [Flightgear-devel] Patch for 3d model_panel

2005-11-30 Thread Harald JOHNSEN

Simon Hollier wrote:


Hello,

Attached is a patch for flightgear and simgear that removes the
model_panel kludge and fixes a potential memory leak.

Thoughts/comments?

Simon
 

I can not test the patch due to lack of time, but I have the impression 
that this is not backward
compatible with the current code, ie since the panel is inserted in the 
scene graph *after*

animations reading you can no more have animations on panels.

Harald.


___
Flightgear-devel mailing list
Flightgear-devel@flightgear.org
http://mail.flightgear.org/mailman/listinfo/flightgear-devel
2f585eeea02e2c79d7b1d8c4963bae2d


[Flightgear-devel] Patch for 3d model_panel

2005-11-29 Thread Simon Hollier
Hello,

Attached is a patch for flightgear and simgear that removes the
model_panel kludge and fixes a potential memory leak.

Thoughts/comments?

Simon

Index: src/Main/renderer.cxx
===
RCS file: /var/cvs/FlightGear-0.9/source/src/Main/renderer.cxx,v
retrieving revision 1.31
diff -u -r1.31 renderer.cxx
--- src/Main/renderer.cxx	8 Nov 2005 10:00:24 -	1.31
+++ src/Main/renderer.cxx	30 Nov 2005 00:12:17 -
@@ -750,7 +750,7 @@
 if ( globals->get_current_panel() != NULL ) {
 globals->get_current_panel()->update(delta_time_sec);
 }
-fgUpdate3DPanels();
+globals->get_aircraft_model()->update3dPanels();
 
 // We can do translucent menus, so why not. :-)
 menus->apply();
Index: src/Input/input.cxx
===
RCS file: /var/cvs/FlightGear-0.9/source/src/Input/input.cxx,v
retrieving revision 1.72
diff -u -r1.72 input.cxx
--- src/Input/input.cxx	23 Nov 2005 12:48:09 -	1.72
+++ src/Input/input.cxx	30 Nov 2005 00:12:19 -
@@ -49,7 +49,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 #include 
@@ -306,7 +306,7 @@
  globals->get_current_panel()->getVisibility() &&
  globals->get_current_panel()->doMouseAction(b, updown, x, y))
   return;
-else if (fgHandle3DPanelMouseEvent(b, updown, x, y))
+else if (globals->get_aircraft_model()->handle3dPanelMouseEvent(b, updown, x, y))
   return;
   }
 
Index: src/Model/Makefile.am
===
RCS file: /var/cvs/FlightGear-0.9/source/src/Model/Makefile.am,v
retrieving revision 1.5
diff -u -r1.5 Makefile.am
--- src/Model/Makefile.am	9 May 2003 20:41:02 -	1.5
+++ src/Model/Makefile.am	30 Nov 2005 00:12:19 -
@@ -2,7 +2,6 @@
 
 libModel_a_SOURCES = \
 acmodel.cxx acmodel.hxx \
-	model_panel.cxx model_panel.hxx \
 modelmgr.cxx modelmgr.hxx \
 panelnode.cxx panelnode.hxx
 
Index: src/Model/acmodel.cxx
===
RCS file: /var/cvs/FlightGear-0.9/source/src/Model/acmodel.cxx,v
retrieving revision 1.15
diff -u -r1.15 acmodel.cxx
--- src/Model/acmodel.cxx	27 Oct 2005 08:40:12 -	1.15
+++ src/Model/acmodel.cxx	30 Nov 2005 00:12:19 -
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -26,7 +27,8 @@
 #include 
 #include 
 
-#include "model_panel.hxx"
+#include "panelnode.hxx"
+#include 
 
 #include "acmodel.hxx"
 
@@ -84,8 +86,12 @@
 
   delete _aircraft;
   delete _scene;
-// SSG will delete it
+
+  // SSG will delete it
   globals->get_scenery()->get_aircraft_branch()->removeKid(_selector);
+
+  // SSG deletes the ssgLeaf panel nodes
+  _panel_nodes.clear();
 }
 
 void 
@@ -107,18 +113,30 @@
   _fgLoaderOptions.livery_path = texture_path;
   }
   try {
-ssgBranch *model = fgLoad3DModelPanel( globals->get_fg_root(),
-   path,
-   globals->get_props(),
-   globals->get_sim_time_sec() );
+vector panel_nodes;
+ssgBranch *model =  sgLoad3DModel( globals->get_fg_root(), 
+path,
+globals->get_props(),
+globals->get_sim_time_sec(),
+&panel_nodes );
+
+for (int i = 0; i < panel_nodes.size(); i++) {
+SG_LOG(SG_INPUT, SG_DEBUG, "Loading a panel");
+FGPanelNode * panel = new FGPanelNode(panel_nodes[i]);
+if (panel_nodes[i]->hasValue("name"))
+panel->setName((char *)panel_nodes[i]->getStringValue("name"));
+addPanelNode(panel);
+model->addKid(panel);
+}
+
 _aircraft->init( model );
   } catch (const sg_exception &ex) {
 SG_LOG(SG_GENERAL, SG_ALERT, "Failed to load aircraft from " << path);
 SG_LOG(SG_GENERAL, SG_ALERT, "(Falling back to glider.ac.)");
-ssgBranch *model = fgLoad3DModelPanel( globals->get_fg_root(),
-   "Models/Geometry/glider.ac",
-   globals->get_props(),
-   globals->get_sim_time_sec() );
+ssgBranch *model = sgLoad3DModel( globals->get_fg_root(),
+   "Models/Geometry/glider.ac",
+   globals->get_props(),
+   globals->get_sim_time_sec() );
 _aircraft->init( model );
   }
   _scene->addKid(_aircraft->getSceneGraph());
@@ -186,4 +204,25 @@
 
 }
 
+void FGAircraftModel::addPanelNode(FGPanelNode * n)
+{
+  _panel_nodes.push_back(n);
+}
+
+void FGAircraftModel::update3dPanels()
+{
+  for (unsigned int i = 0; i < _panel_nodes.size(); i++) {
+_panel_nodes[i]->getPanel