From 09dc4e3b8455e302ee42547f39a6bfbb13a87378 Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 22 Aug 2008 23:43:05 +0000 Subject: [PATCH] add async-load-delay --- panda/src/pgraph/config_pgraph.cxx | 10 ++++++++++ panda/src/pgraph/config_pgraph.h | 1 + panda/src/pgraph/modelLoadRequest.cxx | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/panda/src/pgraph/config_pgraph.cxx b/panda/src/pgraph/config_pgraph.cxx index 82f61aef50..7164850d35 100644 --- a/panda/src/pgraph/config_pgraph.cxx +++ b/panda/src/pgraph/config_pgraph.cxx @@ -274,6 +274,16 @@ ConfigVariableBool flatten_geoms "only the NodePath interfaces; you may still make the lower-level " "SceneGraphReducer calls directly.")); +ConfigVariableDouble async_load_delay +("async-load-delay", 0.0, +PRC_DESC("If this is nonzero, it represents an artificial delay, " + "in seconds, that is imposed on every asynchronous load attempt " + "(within the thread). Its purpose is to help debug errors that " + "may occur when an asynchronous load is delayed. The " + "delay is per-model, and all aync loads will be queued " + "up behind the delay--it is as if the time it takes to read a " + "file is increased by this amount per read.")); + ConfigVariableBool polylight_info ("polylight-info", false, PRC_DESC("Set this true to view some info statements regarding the polylight. " diff --git a/panda/src/pgraph/config_pgraph.h b/panda/src/pgraph/config_pgraph.h index 09d88daef7..f163825042 100644 --- a/panda/src/pgraph/config_pgraph.h +++ b/panda/src/pgraph/config_pgraph.h @@ -53,6 +53,7 @@ extern ConfigVariableInt max_collect_indices; extern ConfigVariableBool premunge_data; extern ConfigVariableBool preserve_geom_nodes; extern ConfigVariableBool flatten_geoms; +extern ConfigVariableDouble async_load_delay; extern ConfigVariableBool polylight_info; extern ConfigVariableDouble lod_fade_time; diff --git a/panda/src/pgraph/modelLoadRequest.cxx b/panda/src/pgraph/modelLoadRequest.cxx index e406353494..ea9bf4e14e 100644 --- a/panda/src/pgraph/modelLoadRequest.cxx +++ b/panda/src/pgraph/modelLoadRequest.cxx @@ -14,6 +14,7 @@ #include "modelLoadRequest.h" #include "loader.h" +#include "config_pgraph.h" TypeHandle ModelLoadRequest::_type_handle; @@ -24,6 +25,11 @@ TypeHandle ModelLoadRequest::_type_handle; //////////////////////////////////////////////////////////////////// bool ModelLoadRequest:: do_task() { + double delay = async_load_delay; + if (delay != 0.0) { + Thread::sleep(delay); + } + Loader *loader; DCAST_INTO_R(loader, _manager, false);