mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
add time_delta interfaces
This commit is contained in:
parent
33886780c4
commit
a552cfa859
@ -111,6 +111,58 @@ get_terrain() const {
|
||||
return _terrain;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: SpeedTreeNode::set_time_delta
|
||||
// Access: Published
|
||||
// Description: Specifies an offset that is to be added each frame to
|
||||
// the global clock's frame_time for the purpose of
|
||||
// animating the trees in this particular node. Also
|
||||
// see set_global_time_delta().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void SpeedTreeNode::
|
||||
set_time_delta(double delta) {
|
||||
_time_delta = delta;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: SpeedTreeNode::get_time_delta
|
||||
// Access: Published
|
||||
// Description: Returns an offset that is to be added each frame to
|
||||
// the global clock's frame_time for the purpose of
|
||||
// animating the trees in this particular node. Also
|
||||
// see get_global_time_delta().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE double SpeedTreeNode::
|
||||
get_time_delta() const {
|
||||
return _time_delta;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: SpeedTreeNode::set_global_time_delta
|
||||
// Access: Published, Static
|
||||
// Description: Specifies an offset that is to be added each frame to
|
||||
// the global clock's frame_time for the purpose of
|
||||
// animating the trees in all SpeedTreeNodes. Also
|
||||
// see set_time_delta().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void SpeedTreeNode::
|
||||
set_global_time_delta(double delta) {
|
||||
_global_time_delta = delta;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: SpeedTreeNode::get_global_time_delta
|
||||
// Access: Published, Static
|
||||
// Description: Returns an offset that is to be added each frame to
|
||||
// the global clock's frame_time for the purpose of
|
||||
// animating the trees in all SpeedTreeNodes. Also
|
||||
// see get_time_delta().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE double SpeedTreeNode::
|
||||
get_global_time_delta() {
|
||||
return _global_time_delta;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: SpeedTreeNode::InstanceList::Constructor
|
||||
// Access: Public
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "dxGraphicsStateGuardian9.h"
|
||||
#endif
|
||||
|
||||
double SpeedTreeNode::_global_time_delta = 0.0;
|
||||
bool SpeedTreeNode::_authorized;
|
||||
bool SpeedTreeNode::_done_first_init;
|
||||
TypeHandle SpeedTreeNode::_type_handle;
|
||||
@ -65,13 +66,14 @@ PStatCollector SpeedTreeNode::_draw_speedtree_terrain_update_pcollector("Draw:Sp
|
||||
////////////////////////////////////////////////////////////////////
|
||||
SpeedTreeNode::
|
||||
SpeedTreeNode(const string &name) :
|
||||
PandaNode(name)
|
||||
PandaNode(name),
|
||||
#ifdef ST_DELETE_FOREST_HACK
|
||||
// Early versions of SpeedTree don't destruct unused CForestRender
|
||||
// objects correctly. To avoid crashes, we have to leak these
|
||||
// things.
|
||||
, _forest_render(*(new SpeedTree::CForestRender))
|
||||
_forest_render(*(new SpeedTree::CForestRender)),
|
||||
#endif
|
||||
_time_delta(0.0)
|
||||
{
|
||||
init_node();
|
||||
// For now, set an infinite bounding volume. Maybe in the future
|
||||
@ -752,6 +754,18 @@ reload_config() {
|
||||
_needs_repopulate = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: SpeedTreeNode::set_wind
|
||||
// Access: Published
|
||||
// Description: Specifies the overall wind strength and direction.
|
||||
// Gusts are controlled internally.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void SpeedTreeNode::
|
||||
set_wind(double strength, const LVector3f &direction) {
|
||||
_forest_render.SetGlobalWindStrength(strength);
|
||||
_forest_render.SetGlobalWindDirection(SpeedTree::Vec3(direction[0], direction[1], direction[2]));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: SpeedTreeNode::authorize
|
||||
// Access: Published, Static
|
||||
@ -791,13 +805,14 @@ SpeedTreeNode::
|
||||
SpeedTreeNode(const SpeedTreeNode ©) :
|
||||
PandaNode(copy),
|
||||
_os_shaders_dir(copy._os_shaders_dir),
|
||||
_shadow_infos(copy._shadow_infos)
|
||||
_shadow_infos(copy._shadow_infos),
|
||||
#ifdef ST_DELETE_FOREST_HACK
|
||||
// Early versions of SpeedTree don't destruct unused CForestRender
|
||||
// objects correctly. To avoid crashes, we have to leak these
|
||||
// things.
|
||||
, _forest_render(*(new SpeedTree::CForestRender))
|
||||
_forest_render(*(new SpeedTree::CForestRender)),
|
||||
#endif
|
||||
_time_delta(copy._time_delta)
|
||||
{
|
||||
init_node();
|
||||
|
||||
@ -963,7 +978,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) {
|
||||
}
|
||||
|
||||
ClockObject *clock = ClockObject::get_global_clock();
|
||||
_forest_render.SetGlobalTime(clock->get_frame_time());
|
||||
_forest_render.SetGlobalTime(clock->get_frame_time() + _time_delta + _global_time_delta);
|
||||
_forest_render.AdvanceGlobalWind();
|
||||
|
||||
// Compute the modelview and camera transforms, to pass to the
|
||||
@ -1281,6 +1296,9 @@ init_node() {
|
||||
|
||||
_forest_render.SetCullCellSize(speedtree_cull_cell_size);
|
||||
|
||||
// Doesn't appear to be necessary to call this explicitly.
|
||||
//_forest_render.EnableWind(true);
|
||||
|
||||
_is_valid = true;
|
||||
}
|
||||
|
||||
@ -1526,7 +1544,12 @@ draw_callback(CallbackData *data) {
|
||||
bool leaf_cards = _forest_render.RenderLeafCards(_visible_trees, SpeedTree::RENDER_PASS_STANDARD, _view);
|
||||
bool billboards = _forest_render.RenderBillboards(_visible_trees, SpeedTree::RENDER_PASS_STANDARD, _view);
|
||||
|
||||
if (!branches || !fronds || !leaf_meshes || !leaf_cards || !billboards) {
|
||||
// Sometimes billboards comes back false, particularly if wind is
|
||||
// disabled; but the billboards appear to have been rendered
|
||||
// successfully. Weird. Just removing this test from the
|
||||
// condition.
|
||||
|
||||
if (!branches || !fronds || !leaf_meshes || !leaf_cards /* || !billboards */) {
|
||||
speedtree_cat.warning()
|
||||
<< "Failed to render forest completely: "
|
||||
<< branches << " " << fronds << " " << leaf_meshes << " " << leaf_cards << " " << billboards << "\n";
|
||||
|
@ -140,6 +140,13 @@ PUBLISHED:
|
||||
|
||||
void reload_config();
|
||||
|
||||
void set_wind(double strength, const LVector3f &direction);
|
||||
|
||||
INLINE void set_time_delta(double delta);
|
||||
INLINE double get_time_delta() const;
|
||||
INLINE static void set_global_time_delta(double delta);
|
||||
INLINE static double get_global_time_delta();
|
||||
|
||||
static bool authorize(const string &license = "");
|
||||
|
||||
public:
|
||||
@ -248,6 +255,9 @@ private:
|
||||
typedef pvector<ShadowInfo> ShadowInfos;
|
||||
ShadowInfos _shadow_infos;
|
||||
|
||||
double _time_delta;
|
||||
static double _global_time_delta;
|
||||
|
||||
static bool _authorized;
|
||||
static bool _done_first_init;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user