Error: too many arguments to function call, expected 0, have 1 mesh->getCachedData(*meshData)


#1

Hello,
I am trying the demo code of Caching part of http://docs.bsframework.io/latest/importing_meshes.html:
// Enable caching
importOptions->setCPUCached(true);
// Import mesh
HMesh mesh = gImporter().import<Mesh>(“dragon.fbx”, importOptions);
// Allocate a buffer to hold mesh contents
SPtr<VertexDataDesc> vertexDesc = VertexDataDesc::create();
vertexDesc->addVertElem(VET_FLOAT3, VES_POSITION);
SPtr<MeshData> meshData = MeshData::create(8, 36, vertexDesc);
// Read cached data
mesh->getCachedData(*meshData);
// Read vertex positions
Vector<Vector3> vertices(8);
meshData->getVertexData(VES_POSITION, vertices.data(), vertices.size() * sizeof(Vector3));

However, it run into an error:
/Users/yingjun/engage/bsfworks/Main.cpp:40:25: error: too many arguments to function
call, expected 0, have 1
mesh->getCachedData(*meshData);
~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~
/Users/yingjun/engage/bsf/include/bsfCore/Mesh/BsMesh.h:114:3: note: ‘getCachedData’
declared here
SPtr getCachedData() const { return mCPUData; }
^
1 error generated.

If I change mesh->getCachedData(*meshData) to mesh->getCachedData(), the compilation will success. And if I comment the line “mesh->getCachedData(*meshData)”, the compilation will success as well.
But I feel there is something wrong here. Can somebody tell me the difference between the above two changes?

Thanks,
Yingjun


#2

SPtr<MeshData> meshData = mesh->getCachedData();

Is the correct way of doing it. The manual was referencing the old API, I’ll submit a fix to change it for the future.


#3

Thanks. After I use “SPtr<MeshData> meshData = mesh->getCachedData()”, I should also change " Vector<Vector3> vertices(8)" to " Vector<Vector3> vertices(8124)". Otherwise it will crash. Is this correct?


#4

I can not find dragon.fbx so I use Drone.fbx instead.


#5

The size of the vertex array depends on the number of vertices in the mesh. You can check it via MeshData::getNumVertices().


#6

Thanks very much. It works.