root/OpenSceneGraph/trunk/src/osgPlugins/OpenFlight/ControlRecords.cpp @ 7859

Revision 7859, 4.5 kB (checked in by robert, 6 years ago)

From Brede Johansen, "Here's a fix to the changes regarding the new dispose() function. The
last primary node inside a push-pop level would not get the dispose()
call. This would result in information from some ancillary records,
like the matrix (transform), being lost.

Changes are made to the latest version in the repository.

Thanks to Terry for the help to find and fix the bug and test the changes."

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
RevLine 
[7748]1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under 
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
13
[5038]14//
15// OpenFlight® loader for OpenSceneGraph
16//
[7748]17//  Copyright (C) 2005-2007  Brede Johansen
[5038]18//
19
[5375]20#include <assert.h>
[5038]21#include <osg/Geode>
22#include <osg/Geometry>
23#include "Registry.h"
24#include "Document.h"
25#include "RecordInputStream.h"
26
27namespace flt {
28
29
30
31/** PushLevel
32*/
33class PushLevel : public Record
34{
35    public:
36
37        PushLevel() {}
38
39        META_Record(PushLevel)
40
[7756]41        virtual void readRecord(RecordInputStream& /*in*/, Document& document)
[5038]42        {
43            document.pushLevel();
44        }
45
46    protected:
47
48        virtual ~PushLevel() {}
49};
50
51RegisterRecordProxy<PushLevel> g_PushLevel(PUSH_LEVEL_OP);
52
53
54/** PophLevel
55*/
56class PopLevel : public Record
57{
58    public:
59
60        PopLevel() {}
61
62        META_Record(PopLevel)
63
[5229]64        virtual void read(RecordInputStream& /*in*/, Document& document)
[5038]65        {
[7859]66            PrimaryRecord* parentPrimary = document.getTopOfLevelStack();
67            PrimaryRecord* currentPrimary = document.getCurrentPrimaryRecord();
68
69            // Call dispose() for primary without push, pop level pair.
70            if (currentPrimary && currentPrimary!=parentPrimary)
[7756]71            {
[7859]72                currentPrimary->dispose(document);
[7756]73            }
74
[7859]75            // Call dispose() for primary with push, pop level pair.
76            if (parentPrimary)
77            {
78                parentPrimary->dispose(document);
79            }
80
[5038]81            document.popLevel();
82        }
83
84    protected:
85
86        virtual ~PopLevel() {}
87};
88
89RegisterRecordProxy<PopLevel> g_PopLevel(POP_LEVEL_OP);
90
91
92/** PushSubface
93*/
94class PushSubface : public Record
95{
96    public:
97
98        PushSubface() {}
99
100        META_Record(PushSubface)
101
[5229]102        virtual void read(RecordInputStream& /*in*/, Document& document)
[5038]103        {
104            document.pushSubface();
105        }
106
107    protected:
108
109        virtual ~PushSubface() {}
110};
111
112RegisterRecordProxy<PushSubface> g_PushSubface(PUSH_SUBFACE_OP);
113
114
115/** PopSubface
116*/
117class PopSubface : public Record
118{
119    public:
120
121        PopSubface() {}
122
123        META_Record(PopSubface)
124
[5229]125        virtual void read(RecordInputStream& /*in*/, Document& document)
[5038]126        {
127            document.popSubface();
128        }
129
130    protected:
131
132        virtual ~PopSubface() {}
133};
134
135RegisterRecordProxy<PopSubface> g_PopSubface(POP_SUBFACE_OP);
136
137
138/** PushExtension
139*/
140class PushExtension : public Record
141{
142    public:
143
144        PushExtension() {}
145
146        META_Record(PushExtension)
147
148        virtual void read(RecordInputStream& in, Document& document)
149        {
150            readRecord(in,document);
151            document.pushExtension();
152        }
153
154    protected:
155
156        virtual ~PushExtension() {}
157};
158
159RegisterRecordProxy<PushExtension> g_PushExtension(PUSH_EXTENSION_OP);
160
161
162/** PopExtension
163*/
164class PopExtension : public Record
165{
166    public:
167
168        PopExtension() {}
169
170        META_Record(PopExtension)
171
172        virtual void read(RecordInputStream& in, Document& document)
173        {
174            readRecord(in,document);
175            document.popExtension();
176        }
177
178    protected:
179
180        virtual ~PopExtension() {}
181};
182
183RegisterRecordProxy<PopExtension> g_PopExtension(POP_EXTENSION_OP);
184
185
186/** PushAttribute - Reserved subtree
187*/
188class PushAttribute : public Record
189{
190    public:
191
192        PushAttribute() {}
193
194        META_Record(PushAttribute)
195
196        virtual void read(RecordInputStream& in, Document& document)
197        {
198            readRecord(in,document);
199        }
200
201    protected:
202
203        virtual ~PushAttribute() {}
204};
205
206RegisterRecordProxy<PushAttribute> g_PushAttribute(PUSH_ATTRIBUTE_OP);
207
208
209/** PopAttribute
210*/
211class PopAttribute : public Record
212{
213    public:
214
215        PopAttribute() {}
216
217        META_Record(PopAttribute)
218
219        virtual void read(RecordInputStream& in, Document& document)
220        {
221            readRecord(in,document);
222        }
223
224    protected:
225
226        virtual ~PopAttribute() {}
227};
228
229RegisterRecordProxy<PopAttribute> g_PopAttribute(POP_ATTRIBUTE_OP);
230
231
232} // end namespace
233
234
Note: See TracBrowser for help on using the browser.