Skip to content

Commit ce4e89c

Browse files
committed
LoaderOptions, supporting auto-converting animation from maya filess
1 parent 71f3a95 commit ce4e89c

23 files changed

+202
-18
lines changed

panda/src/egg2pg/loaderFileTypeEgg.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ get_extension() const {
5858
// Description:
5959
////////////////////////////////////////////////////////////////////
6060
PT(PandaNode) LoaderFileTypeEgg::
61-
load_file(const Filename &path, bool) const {
61+
load_file(const Filename &path, const LoaderOptions &) const {
6262
PT(PandaNode) result = load_egg_file(path);
6363
return result;
6464
}

panda/src/egg2pg/loaderFileTypeEgg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class EXPCL_PANDAEGG LoaderFileTypeEgg : public LoaderFileType {
3434
virtual string get_name() const;
3535
virtual string get_extension() const;
3636

37-
virtual PT(PandaNode) load_file(const Filename &path, bool report_errors) const;
37+
virtual PT(PandaNode) load_file(const Filename &path, const LoaderOptions &optoins) const;
3838

3939
public:
4040
static TypeHandle get_class_type() {

panda/src/framework/pandaFramework.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#include "mouseAndKeyboard.h"
3030
#include "mouseRecorder.h"
3131

32+
LoaderOptions PandaFramework::_loader_options;
33+
3234
////////////////////////////////////////////////////////////////////
3335
// Function: PandaFramework::Constructor
3436
// Access: Public

panda/src/framework/pandaFramework.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ class EXPCL_FRAMEWORK PandaFramework {
114114
INLINE void set_exit_flag();
115115
INLINE void clear_exit_flag();
116116

117+
public:
118+
static LoaderOptions _loader_options;
119+
117120
protected:
118121
virtual PT(WindowFramework) make_window_framework();
119122
virtual void make_default_pipe();

panda/src/framework/windowFramework.cxx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,12 +571,19 @@ load_model(const NodePath &parent, Filename filename) {
571571
}
572572
}
573573

574+
LoaderOptions options = PandaFramework::_loader_options;
575+
if (search) {
576+
options.set_flags(options.get_flags() | LoaderOptions::LF_search);
577+
} else {
578+
options.set_flags(options.get_flags() & ~LoaderOptions::LF_search);
579+
}
580+
574581
Loader loader;
575582
PT(PandaNode) node;
576583
if (is_image) {
577584
node = load_image_as_model(filename);
578585
} else {
579-
node = loader.load_sync(filename, search);
586+
node = loader.load_sync(filename, options);
580587
}
581588

582589
if (node == (PandaNode *)NULL) {

panda/src/framework/windowFramework.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "pvector.h"
3333
#include "typedWritableReferenceCount.h"
3434
#include "graphicsWindow.h"
35+
#include "loaderOptions.h"
3536

3637
class PandaFramework;
3738
class AmbientLight;

panda/src/pgraph/Sources.pp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
loaderFileType.h \
6565
loaderFileTypeBam.h \
6666
loaderFileTypeRegistry.h \
67+
loaderOptions.I loaderOptions.h \
6768
lodNode.I lodNode.h \
6869
materialAttrib.I materialAttrib.h \
6970
modelNode.I modelNode.h \
@@ -169,6 +170,7 @@
169170
loaderFileType.cxx \
170171
loaderFileTypeBam.cxx \
171172
loaderFileTypeRegistry.cxx \
173+
loaderOptions.cxx \
172174
lodNode.cxx \
173175
materialAttrib.cxx \
174176
modelNode.cxx \
@@ -268,6 +270,7 @@
268270
loaderFileType.h \
269271
loaderFileTypeBam.h \
270272
loaderFileTypeRegistry.h \
273+
loaderOptions.I loaderOptions.h \
271274
lodNode.I lodNode.h \
272275
materialAttrib.I materialAttrib.h \
273276
modelNode.I modelNode.h \

panda/src/pgraph/loader.I

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ add_file(const Filename &file, LoaderFileType *type) {
123123
// loaded.
124124
////////////////////////////////////////////////////////////////////
125125
INLINE PT(PandaNode) Loader::
126-
load_sync(const Filename &filename, bool search) const {
126+
load_sync(const Filename &filename, const LoaderOptions &options) const {
127127
if (!_file_types_loaded) {
128128
load_file_types();
129129
}
130-
return load_file(filename, search);
130+
return load_file(filename, options);
131131
}

panda/src/pgraph/loader.cxx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,10 +407,12 @@ process_request() {
407407
// loaded.
408408
////////////////////////////////////////////////////////////////////
409409
PT(PandaNode) Loader::
410-
load_file(const Filename &filename, bool search) const {
410+
load_file(const Filename &filename, const LoaderOptions &options) const {
411411
Results results;
412412
int num_files;
413413

414+
bool search = (options.get_flags() & LoaderOptions::LF_search) != 0;
415+
414416
if (search) {
415417
// Look for the file along the model path.
416418
num_files = find_all_files(filename, get_model_path(), results);
@@ -452,7 +454,7 @@ load_file(const Filename &filename, bool search) const {
452454
for (int i = 0; i < num_files; ++i) {
453455
const Filename &path = results.get_file(i);
454456
LoaderFileType *type = results.get_file_type(i);
455-
PT(PandaNode) result = type->load_file(path, true);
457+
PT(PandaNode) result = type->load_file(path, options);
456458
if (result != (PandaNode *)NULL) {
457459
return result;
458460
}

panda/src/pgraph/loader.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "pandabase.h"
2323

24+
#include "loaderOptions.h"
2425
#include "notify.h"
2526
#include "pandaNode.h"
2627
#include "filename.h"
@@ -71,7 +72,8 @@ class EXPCL_PANDA Loader : public AsyncUtility {
7172
int find_all_files(const Filename &filename, const DSearchPath &search_path,
7273
Results &results) const;
7374

74-
INLINE PT(PandaNode) load_sync(const Filename &filename, bool search = true) const;
75+
INLINE PT(PandaNode) load_sync(const Filename &filename,
76+
const LoaderOptions &options = LoaderOptions()) const;
7577

7678
uint request_load(const string &event_name, const Filename &filename, bool search = true);
7779
bool check_load(uint id);
@@ -82,7 +84,7 @@ class EXPCL_PANDA Loader : public AsyncUtility {
8284
static bool _file_types_loaded;
8385

8486
virtual bool process_request();
85-
PT(PandaNode) load_file(const Filename &filename, bool search) const;
87+
PT(PandaNode) load_file(const Filename &filename, const LoaderOptions &options) const;
8688

8789
typedef TokenBoard<LoaderToken> LoaderTokenBoard;
8890
LoaderTokenBoard *_token_board;

0 commit comments

Comments
 (0)