Why is this object disconnected and deleted?

Through the debugger, the BBox object is in order of access to the function, but as soon as it enters this function, the vfptr object points to 0xccccc. I do not understand.

  • What causes this?
  • Why is there a link to a virtual table where the object is not derived from another class. (Although it is located in the GameObject from which my Player class is inherited, and I retrieve the BBox from within the player. But why does the BBox have a link? Isn't it the player that should be supported in this link?)

For 1; some code for reference:

and. I remove the bounding box from the player. This returns the frame as expected. Then I submit my address to GetGridCells.

 const BoundingBox& l_Bbox = l_pPlayer->GetBoundingBox();

 boost::unordered_set < Cell*, CellPHash >& l_GridCells = GetGridCells ( &l_Bbox ); 

B. Here a_pBoundingBox goes crazy and gets this garbage value.

 boost::unordered_set< Cell*, CellPHash > CollisionMgr::GetGridCells(const BoundingBox *a_pBoundingBox)
 {

, , :

 const BoundingBox& Player::GetBoundingBox(void)
 {
 return BoundingBox( &GetBoundingSphere() );
 }

 const BoundingSphere& Player::GetBoundingSphere(void)
 {
 BoundingSphere& l_BSphere = m_pGeomMesh->m_BoundingSphere;

 l_BSphere.m_Center = GetPosition();

 return l_BSphere;
 }

 // BoundingBox Constructor
 BoundingBox(const BoundingSphere* a_pBoundingSphere);

-, , , ? , , , , .

!

0
3
 const BoundingBox& Player::GetBoundingBox(void)
 {
 return BoundingBox( &GetBoundingSphere() );
 }

BoundingBox. , return.

a BoundingBox BoundingBox&.


:

 BoundingSphere& l_BSphere = m_pGeomMesh->m_BoundingSphere;

 l_BSphere.m_Center = GetPosition();

m_pGeomMesh, , . . , , ?


:

 // BoundingBox Constructor
 BoundingBox(const BoundingSphere* a_pBoundingSphere);

, , . ?

+3
  • , BoundingBox return return, . ( ). - - , .
  • vtable , - , . , , vtable . , .
0

@Thomas: m :

#ifndef BOUNDINGBOX_H
#define BOUNDINGBOX_H

class BoundingSphere;

class BoundingBox
{
public:

    BoundingBox(const BoundingSphere* a_pBoundingSphere);
    //BoundingBox( const BoundingBox& rhs);
    virtual ~BoundingBox(void);

    const std::vector< glm::vec3 > GetCorners() const;

    glm::vec3 m_Center;
    glm::vec3 m_Extents;        // extents along the X, Y, Z axis for the bounding box positioned at the center
};

#endif

#ifndef BOUNDINGSPHERE_H
#define BOUNDINGSPHERE_H

class BoundingBox;

class BoundingSphere
{
public:
    BoundingSphere();

BoundingSphere(const BoundingBox* a_pBoundingBox);

    BoundingSphere(const glm::vec3& a_Center, const float& a_Radius);
    virtual ~BoundingSphere(void);

    // Access the Center
    const glm::vec3 &GetCenter(void) const  { return(m_Center);     };
    void SetCenter(const glm::vec3 &Center) { m_Center = Center;    };

    // Access the Radius
    float GetRadius(void) const     { return(m_Radius);     };
    void SetRadius(float Radius)    { m_Radius = Radius;    };

    glm::vec3 m_Center;
    float m_Radius;
};

#endif

, : BoundingBox BoundingSphere, ..

BoundingBox(const BoundingSphere& a_pBoundingSphere);

This would require defining BoundingSphere at the time of compilation. Therefore, I have to include BoundingSphere.h in BoundingBox.h to make the definition available. This is true for the other way around and thereby creates circular references.

Please correct me on this ..

thank

0
source

All Articles