Skip to content

Commit 08a66da

Browse files
committed
independent footprint/trail length for each model
1 parent e910640 commit 08a66da

File tree

6 files changed

+27
-21
lines changed

6 files changed

+27
-21
lines changed

libstage/canvas.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,11 @@ void Canvas::renderFrame()
999999
colorstack.Push(0.8, 0.8, 1.0); // pale blue
10001000
glRectf(0, 0, width, height);
10011001
colorstack.Push(0, 0, 0); // black
1002-
Gl::draw_string(margin, margin, 0, clockstr.c_str());
1002+
1003+
//char buf[ clockstr.size() ];
1004+
//strcpy( buf, clockstr.c_str() );
1005+
1006+
Gl::draw_string(margin, margin, 0, clockstr.c_str() );
10031007
colorstack.Pop();
10041008
colorstack.Pop();
10051009

libstage/model.cc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ using namespace Stg;
144144

145145
// static members
146146
uint32_t Model::count(0);
147-
uint32_t Model::trail_length(50);
148-
uint64_t Model::trail_interval(5);
149147
std::map<Stg::id_t, Model *> Model::modelsbyid;
150148
std::map<std::string, creator_t> Model::name_map;
151149

@@ -238,8 +236,8 @@ Model::Model(World *world, Model *parent, const std::string &type, const std::st
238236
interval_energy((usec_t)1e5), // 100msec
239237
last_update(0), log_state(false), map_resolution(0.1), mass(0), parent(parent), pose(),
240238
power_pack(NULL), pps_charging(), rastervis(), rebuild_displaylist(true), say_string(),
241-
stack_children(true), stall(false), subs(0), thread_safe(false), trail(trail_length),
242-
trail_index(0), type(type), event_queue_num(0), used(false), watts(0.0), watts_give(0.0),
239+
stack_children(true), stall(false), subs(0), thread_safe(false), trail(20),
240+
trail_index(0), trail_interval(10), type(type), event_queue_num(0), used(false), watts(0.0), watts_give(0.0),
243241
watts_take(0.0), wf(NULL), wf_entity(0), world(world),
244242
world_gui(dynamic_cast<WorldGui *>(world))
245243
{
@@ -735,7 +733,7 @@ void Model::UpdateTrail()
735733
item->color = color;
736734

737735
// wrap around ring buffer
738-
trail_index %= trail_length;
736+
trail_index %= trail.size();
739737
}
740738

741739
Model *Model::GetUnsubscribedModelOfType(const std::string &type) const
@@ -1407,9 +1405,8 @@ void Model::Load()
14071405

14081406
Say(wf->ReadString(wf_entity, "say", ""));
14091407

1410-
trail_length = wf->ReadInt(wf_entity, "trail_length", trail_length);
1408+
int trail_length = wf->ReadInt(wf_entity, "trail_length", (int)trail.size() );
14111409
trail.resize(trail_length);
1412-
14131410
trail_interval = wf->ReadInt(wf_entity, "trail_interval", trail_interval);
14141411

14151412
this->alwayson = wf->ReadInt(wf_entity, "alwayson", alwayson);

libstage/model_draw.cc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,27 @@ void Model::DrawSelected()
4949
void Model::DrawTrailFootprint()
5050
{
5151
double darkness = 0;
52-
double fade = 0.5 / (double)(trail_length + 1);
52+
double fade = 0.5 / (double)(trail.size() + 1);
5353

5454
PushColor(0, 0, 0, 1); // dummy push just saving the color
5555

5656
// this loop could be faster, but optimzing vis is not a priority
57-
for (unsigned int i = 0; i < trail_length; i++) {
57+
58+
for (unsigned int i = 0; i < trail.size(); i++) {
59+
5860
// find correct offset inside ring buffer
59-
TrailItem &checkpoint = trail[(i + trail_index) % trail_length];
60-
61+
TrailItem &checkpoint = trail[(i + trail_index) % trail.size()];
62+
6163
// ignore invalid items
6264
if (checkpoint.time == 0)
6365
continue;
64-
66+
6567
glPushMatrix();
6668
Pose pz = checkpoint.pose;
67-
69+
6870
Gl::pose_shift(pz);
6971
Gl::pose_shift(geom.pose);
70-
72+
7173
darkness += fade;
7274
Color c = checkpoint.color;
7375
c.a = darkness;

libstage/stage.hh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1868,13 +1868,13 @@ allow parallel Updates(). */
18681868
/** current position in the ring buffer */
18691869
unsigned int trail_index;
18701870

1871-
/** The maxiumum length of the trail drawn. Default is 20, but can
1872-
be set in the world file using the trail_length model
1873-
property. */
1874-
static unsigned int trail_length;
1871+
// /** The maxiumum length of the trail drawn. Default is 20, but can
1872+
// be set in the world file using the trail_length model
1873+
// property. */
1874+
// unsigned int trail_length;
18751875

18761876
/** Number of world updates between trail records. */
1877-
static uint64_t trail_interval;
1877+
uint64_t trail_interval;
18781878

18791879
/** Record the current pose in our trail. Delete the trail head if it is full. */
18801880
void UpdateTrail();

libstage/worldgui.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,8 @@ bool WorldGui::Update()
400400
// inherit
401401
const bool done = World::Update();
402402

403-
if (Model::trail_length > 0 && updates % Model::trail_interval == 0)
404403
FOR_EACH (it, active_velocity)
404+
if ((*it)->trail.size() > 0 && updates % (*it)->trail_interval == 0)
405405
(*it)->UpdateTrail();
406406

407407
if (done) {

worlds/simple.world

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ pioneer2dx
5555
# report error-free position in world coordinates
5656
localization "gps"
5757
localization_origin [ 0 0 0 0 ]
58+
59+
trail_length 400
60+
5861
)
5962

6063
pioneer2dx

0 commit comments

Comments
 (0)