Skip to content

Commit 17e90c1

Browse files
author
Lucio Moser
committed
Fixing previous change on the firstReader() implementation.
Some of the functions in the class (hash functions and geometry compute) were using data that was not coming from the firstReader, leading to crashes. In order to solve the problem and prevent future ones, I've isolated all the member functions that should be shared into a private class that only the firstReader allocates. Also, all the member functions that are supposed to be used only by the firstReader have an assert() statement to document it. Lastly, during this process I've realized that some of the data variables that are linked to the knobs were being overwritten during the knob_changed() function, which would create disparity to the non-firstReader instances. So I've created additional ones in the shared data.
1 parent 29ab467 commit 17e90c1

File tree

2 files changed

+229
-147
lines changed

2 files changed

+229
-147
lines changed

include/IECoreNuke/SceneCacheReader.h

Lines changed: 15 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//////////////////////////////////////////////////////////////////////////
22
//
3-
// Copyright (c) 2013, Image Engine Design Inc. All rights reserved.
3+
// Copyright (c) 2013-2014, Image Engine Design Inc. All rights reserved.
44
//
55
// Redistribution and use in source and binary forms, with or without
66
// modification, are permitted provided that the following conditions are
@@ -145,40 +145,26 @@ class SceneCacheReader : public DD::Image::SourceGeo
145145

146146
Imath::M44d worldTransform( IECore::ConstSceneInterfacePtr scene, IECore::SceneInterface::Path root, double time );
147147

148-
// uses firstOp to return the Op that has the up-to-date private data
149-
SceneCacheReader *firstReader();
150-
151148
/// Returns an InternedString with the name of the geometry tag.
152149
static const IECore::InternedString &geometryTag();
153150

151+
// uses firstOp to return the Op that has the up-to-date private data
152+
SceneCacheReader *firstReader();
153+
const SceneCacheReader *firstReader() const;
154+
155+
class SharedData;
156+
157+
// this function should only be called from the firstReader() object.
158+
SharedData *sharedData();
159+
const SharedData *sharedData() const;
160+
154161
// Knob Members.
155162
const char *m_filePath; // Holds the raw SceneCache file path.
156-
std::string m_evaluatedFilePath; // Holds the SceneCache file path after any TCL scripts have been evaluated..
157163
std::string m_root; // Holds the root item in the SceneCache.
158-
std::string m_filterText; // The text to filter the scene with.
159-
std::string m_filterTagText; // The text to filter the tags with. This is set from the Enumeration_knob.
164+
std::string m_filter; // The text to filter the scene with.
160165
bool m_worldSpace; // Set to ignore local transforms..
161166
DD::Image::Matrix4 m_baseParentMatrix; // The global matrix that is applied to the geo.
162-
163-
// Hashes that are used to both provide an early-out to some methods
164-
// and also contribute towards a hash for the geometry.
165-
DD::Image::Hash m_selectionHash;
166-
DD::Image::Hash m_filterHash;
167-
DD::Image::Hash m_sceneHash;
168-
169-
// When buildSceneView is called to parse the scene cache and generate a list of entries for the SceneView_knob,
170-
// this map is also populated. It holds a mapping of tag names to the indices of items which have that tag.
171-
// It is used within the filterScene method to quickly filter items with a particular tag.
172-
typedef std::map< std::string, std::vector< unsigned int > > TagMap;
173-
TagMap m_tagMap;
174-
175-
// When specifying a root we store the path to it's parent item along with the length of it. We do this so that when
176-
// we are building the list of items in the SceneView_knob we can strip this path quickly from the front of the
177-
// name and easily restore it later to load it from the SceneCache. This ensures that the names of the items in the
178-
// SceneView_knob are kept short.
179-
std::string m_pathPrefix;
180-
unsigned int m_pathPrefixLength;
181-
167+
182168
// Pointers to various knobs.
183169
DD::Image::Knob *m_filePathKnob;
184170
DD::Image::Knob *m_baseParentMatrixKnob;
@@ -187,19 +173,8 @@ class SceneCacheReader : public DD::Image::SourceGeo
187173
DD::Image::Knob *m_sceneFilterKnob;
188174
DD::Image::Knob *m_rootKnob;
189175

190-
// A flag which is set when all of the knobs have been loaded from the script.
191-
bool m_scriptFinishedLoading;
192-
193-
// A flag which is used to initialize the internal data structures the first time the node is run.
194-
bool m_isFirstRun;
195-
196-
/// The SceneView_knob holds a list of all leaf items in the scene. When filtering the SceneView we specify indices into
197-
/// this list. When setting or querying the selected items in the SceneView_knob we need to use indices into the list of
198-
/// filtered (visible) items. This means that we have to keep a look-up table of mappings between indices in the filtered
199-
/// list of items and the index within the complete list of items in the scene.
200-
std::map<int, int> m_itemToFiltered; // Mapping of the index within the full scene list and the filtered scene list.
201-
std::vector<unsigned int> m_filteredToItem; // Mapping from an index in the filtered scene list to the complete scene list.
202-
std::vector< bool > m_itemSelected; // An array of flags which indicate whether an item in the filtered list is selected or not.
176+
// only the first reader allocates the shared data
177+
SharedData *m_data;
203178
};
204179

205180
} // namespace IECoreNuke

0 commit comments

Comments
 (0)