I have 2 classes: MeshInput and VoxelGrid. VoxelGrid has the member sdf which is a function pointer. Now I want to assign a non static function of another class to sdf. I can't change the signature of either because sdf also sometimes points to a function outside of MeshInput. How do I do that?
Code below:
class VoxelGrid {
private:
double (*sdf)(tg::pos3 const&);
}
class MeshInput {
public:
double sdfFromMesh(tg::pos3 const& point);
}
From my understanding the Issue is that when calling the function with the function pointer there is no implicit this* pointer like when calling it from an object (A.sdfFromMesh()). But I don't know how to work around that.
double (tg::pos3 const&)signature, its first argument is a pointer to the object. Can you change your raw pointer tostd::function<double(tg::pos3 const&)>?virtual?