Author Topic: BSP Difficulty  (Read 7031 times)

Fenrir

  • Rogueliker
  • ***
  • Posts: 473
  • Karma: +1/-2
  • The Monstrous Wolf
    • View Profile
BSP Difficulty
« on: July 27, 2010, 04:51:00 PM »
Using C++ and PDCurses

I'm working on binary space partitioning for dungeon generation. Every BSP node should point to its parent, sibling, and children, but I can't do the following.

Code: [Select]
class BSP
{
private:
BSP * m_parent, m_sibling, m_childA, m_childB;
int m_depth;
int m_x, m_y, m_width, m_height;

public:
BSP(void);
~BSP(void);

const BSP * const parent() const;
const BSP * const sibling() const;
const BSP * const childA() const;
const BSP * const childB() const;

int depth() const;
void depth(int depth);

int x() const;
void x(int x);

int y() const;
void y(int y);

int width() const;
void width(int width);

int height() const;
void height(int height);
};

BSP is being defined, so I can't have member variables that are pointers to BSP objects. What should I do about it?

Tapio

  • Newcomer
  • Posts: 46
  • Karma: +2/-1
    • View Profile
    • Email
Re: BSP Difficulty
« Reply #1 on: July 27, 2010, 05:03:16 PM »
Yes you can. You just misused the syntax, it should be:
Code: [Select]
private:
BSP *m_parent, *m_sibling, *m_childA, *m_childB;

or less error prone:
Code: [Select]
private:
    BSP* m_parent;
    BSP* m_sibling;
    BSP* m_childA;
    BSP* m_childB;

Fenrir

  • Rogueliker
  • ***
  • Posts: 473
  • Karma: +1/-2
  • The Monstrous Wolf
    • View Profile
Re: BSP Difficulty
« Reply #2 on: July 27, 2010, 08:03:07 PM »
Fenrir rolls his eyes and paws his face in disgust.

Oh. Thanks, aave.