Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/lib/coord/null_parent.cc @ 3532

Last change on this file since 3532 was 3529, checked in by patrick, 20 years ago

orxonox/trunk: zero-loop problem in pnode, dynamic pnode realocation. unstable, segfault when changing level.

File size: 2.2 KB
Line 
1
2
3/*
4   orxonox - the future of 3D-vertical-scrollers
5
6   Copyright (C) 2004 orx
7
8   This program is free software; you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2, or (at your option)
11   any later version.
12
13   ### File Specific:
14   main-programmer: Patrick Boenzli
15   co-programmer: ...
16*/
17
18
19#include "null_parent.h"
20
21
22using namespace std;
23
24NullParent* NullParent::singletonRef = 0;
25
26NullParent* NullParent::getInstance ()
27{
28  if( singletonRef == NULL)
29    singletonRef = new NullParent ();
30  return singletonRef;
31}
32
33/**
34   \brief standard constructor
35
36   \todo this constructor is not jet implemented - do it
37*/
38NullParent::NullParent () : PNode("NullParent")
39{
40  printf("NullParent::NullParent() - making new NullParent, there can only be one..\n");
41  this->parent = this;
42  this->mode = ALL;
43  this->setName("NullParent");
44}
45
46
47NullParent::NullParent (Vector* absCoordinate) : PNode("NullParent")
48{
49  this->parent = this;
50  this->mode = ALL;
51  this->absCoordinate = *absCoordinate;
52  this->setName("NullParent");
53}
54
55
56/**
57   \brief standard deconstructor
58
59   \todo this deconstructor is not jet implemented - do it
60*/
61NullParent::~NullParent () 
62{
63  //delete singletonRef;
64  singletonRef = NULL;
65}
66
67
68
69
70/**
71   \brief updates the absCoordinate/absDirection
72
73   this is used to go through the parent-tree to update all the absolute coordinates
74   and directions. this update should be done by the engine, so you don't have to
75   worry, normaly...
76*/
77void NullParent::update (float timeStamp)
78{
79  this->absCoordinate = this->relCoordinate;
80  this->absDirection = parent->getAbsDir () * this->relDirection;
81 
82  PNode* pn = this->children->enumerate ();
83  while( pn != NULL) 
84    { 
85      /* if this node has changed, make sure, that all children are updated also */
86      if( this->bRelCoorChanged || this->bAbsCoorChanged)
87        pn->parentCoorChanged ();
88      if( this->bRelDirChanged || this->bAbsDirChanged)
89        pn->parentDirChanged ();
90      pn->update (timeStamp);
91      pn = this->children->nextElement ();
92    }
93
94  this->timeStamp = timeStamp;
95  this->bRelCoorChanged = false;
96  this->bAbsCoorChanged = false;
97  this->bRelDirChanged = false;
98  this->bAbsDirChanged = false;
99}
Note: See TracBrowser for help on using the repository browser.