Skip to content

Suspicious virtual destructor in CCBundle3DData.h #19754

@JohnCoconut

Description

@JohnCoconut

cocos/3d/CCBundle3DData.h has a few structure storing 3D data. But some comes with virtual destructor, some doesn't.

struct ModelData
{
    std::string subMeshId;
    std::string materialId;
    std::vector<std::string> bones;
    std::vector<Mat4>        invBindPose;
    
    virtual ~ModelData()
    {   
        resetData();
    }   
    virtual void resetData()
    {   
        bones.clear();
        invBindPose.clear();
    }   
};

struct MeshDatas
{
    std::vector<MeshData*> meshDatas;
    
    void resetData()
    {
        for(auto& it : meshDatas)
        {
            delete it;
        }
        meshDatas.clear();
    }
    ~MeshDatas()
    {
        resetData();
    }
};  

And no class seems to inherit from struct ModelData. Is it a mistake to include virtual keyword?

@minggo If you think virtual is unnecessary, I will remove it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions