0

So I have this class and struct:

class ISDFParams
{
public:
    virtual ~ISDFParams() = default;
    Vector3 point;
};

struct SDFSphereParams : public ISDFParams {
public:
    float radius;
};

I use it later like this

SDFSphereParams p;
p.radius = 4;

GetDensityData(p);

In GetDensityData(ISDFParams sdfParams) I do

SDFSphereParams* _params = (SDFSphereParams*)&params;

The problem is when I print _params->radius its anything else but 4.

What am I doing wrong?

P.S. I know the example is a bit pointless, but the original code is rather long so I cut down it my problem.

trshmanx
  • 600
  • 7
  • 16

0 Answers0