rjohnson
I'm getting crashes related to the clipmap when editing voxels. I'm using the latest 3.0.1.7. It seems it has something to do with the latest release as this stuff was working fine in the previous release. I've tried 2 different methods.

The first uses VoxelFarm::cursorPaint and then calls clipmap.processModifiedCells directly.
Stack Trace of Crashed Thread 56752:
0x00007FFB7EF22648 (MSVCP140) Thrd_yield
0x00007FFB3393A452 (voxelfarm) [c:\program files\voxel farm\sdk\plugin.dll\voxelfarmevents.h:26] VoxelFarm::Client::CVoxelFarm::CMyDemoEvents::cellsPending
0x00007FFB3398CA6C (voxelfarm) VoxelFarm::CClipmapView:😋rocessModifiedCells
0x00007FFB33968CBC (voxelfarm) [c:\program files\voxel farm\sdk\plugin.dll\voxelfarm_unity.cpp:1991] paintMaterial
0x000002B3A29E752D (CivCraft) CivCraft.RoadPlacer.paintMaterial()
0x000002B3A29E69C3 (CivCraft) CivCraft.RoadPlacer.PaintRoad()
0x000002B342E9423B (CivCraft) CivCraft.RoadPlacer.Update()
0x000002B3A85CB738 (mscorlib) System.Object.runtime_invoke_void__this__()
0x00007FFB4D35CBD0 (mono-2.0-bdwgc) mono_get_runtime_build_info
0x00007FFB4D2E2142 (mono-2.0-bdwgc) mono_perfcounters_init
0x00007FFB4D2EB13F (mono-2.0-bdwgc) mono_runtime_invoke
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF775B6D0FE)
0x00007FF775B6D0FE (Unity) (function-name not available)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF775B66DDD)
0x00007FF775B66DDD (Unity) (function-name not available)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF775B30975)
0x00007FF775B30975 (Unity) (function-name not available)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF775B30A86)
0x00007FF775B30A86 (Unity) (function-name not available)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF7751E3058)
0x00007FF7751E3058 (Unity) (function-name not available)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF7751EC074)
0x00007FF7751EC074 (Unity) (function-name not available)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF775617153)
0x00007FF775617153 (Unity) (function-name not available)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF775600598)
0x00007FF775600598 (Unity) (function-name not available)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF77560066D)
0x00007FF77560066D (Unity) (function-name not available)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF775605864)
0x00007FF775605864 (Unity) (function-name not available)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF773A2EC6B)
0x00007FF773A2EC6B (Unity) (function-name not available)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF773A2CBA8)
0x00007FF773A2CBA8 (Unity) (function-name not available)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF774367890)
0x00007FF774367890 (Unity) (function-name not available)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF77437150A)
0x00007FF77437150A (Unity) (function-name not available)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF7772E0342)
0x00007FF7772E0342 (Unity) (function-name not available)
0x00007FFBC5157BD4 (KERNEL32) BaseThreadInitThunk
0x00007FFBC6F6CED1 (ntdll) RtlUserThreadStart


The second called CVoxelFarm.paintMesh :
Stack Trace of Crashed Thread 53756:
0x00007FFB817F2648 (MSVCP140) Thrd_yield
0x00007FFB3E10A452 (voxelfarm) [c:\program files\voxel farm\sdk\plugin.dll\voxelfarmevents.h:26] VoxelFarm::Client::CVoxelFarm::CMyDemoEvents::cellsPending
0x00007FFB3E15CA6C (voxelfarm) VoxelFarm::CClipmapView:😋rocessModifiedCells
0x00007FFB3E109746 (voxelfarm) [c:\program files\voxel farm\sdk\plugin.dll\voxelfarmimpl.h:1078] VoxelFarm::Client::CVoxelFarm::CVoxelFarmImpl::applyEdition
0x00007FFB3E10CDC0 (voxelfarm) [c:\program files\voxel farm\sdk\plugin.dll\voxelfarminit.cpp:1301] VoxelFarm::Client::CVoxelFarm::EditionWork
0x00007FFB3E114A22 (voxelfarm) [c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\thr\xthread:230] std::_LaunchPad<std::unique_ptr<std::tuple<void (__cdecl VoxelFarm::Client::CVoxelFarm::*)(void),VoxelFarm::Client::CVoxelFarm *>,std:😃efault_delete<std::tuple<void (__cdecl VoxelFarm::Client::CVoxelFarm::*)(void),VoxelFarm::Client::CVoxelFarm *> > > >::_Go
0x00007FFB3E102D89 (voxelfarm) [c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\thr\xthread:209] std::_Pad::_Call_func
0x00007FFBC49F0E72 (ucrtbase) beginthreadex
0x00007FFBC5157BD4 (KERNEL32) BaseThreadInitThunk
0x00007FFBC6F6CED1 (ntdll) RtlUserThreadStart
0 0
Ericool
Hi rjohnson,
We are unable to reproduce any crash with paintBlock. Do you have any issue when using this function?
I see you are calling paintMesh and cursorPaint maybe differently than what we do. Do you have any code/implementation to share us as the dll you used does not match the one we released. So that we can investigate further why you have crashes.
0 0
rjohnson
I had made some changes to CVoxelFarm to make 

class CVoxelFarmImpl;
CVoxelFarmImpl* pimpl;


public again (I think the protection level changed after the latest VF release) so that I could get access to the clipmap again in order to call processModifiedCells from within voxelfarm_unity.cpp
Like so : 

class CVoxelFarm
{
private:
TSet<CellId> discardedCells;
protected:

class CMyDemoEvents;
CMyDemoEvents* events;

const SceneConfiguration sceneConfiguration;
const CellConfiguration cellConfiguration;
const InstanceReferenceConfiguration instanceReferenceConfiguration;
const NavMeshConfiguration navMeshConfiguration;

public:

class CVoxelFarmImpl;
CVoxelFarmImpl* pimpl;


It looks like that change was causing paintBlock to crash.  
So I have a new question, should I be accessing the clipmap directly in voxelfarm_unity.cpp. If so, what's the proper way to get at it?
This is the paint function I had working prior to upgrading to the latest version : 

This line would not work with the new version: 
CClipmapView* clipmap = vfImpl->vf->clipmapView();


bool VOXELFARM_API paintMaterial(
double rayOriginX,
double rayOriginY,
double rayOriginZ,
double rayDirectionX,
double rayDirectionY,
double rayDirectionZ,
unsigned int sizeX,
unsigned int sizeY,
unsigned int sizeZ,
bool snapToGrid,
bool cubeBrush,
uint16_t paintMaterial,
uint16_t* hitMaterialUid,
double* hitPositionX,
double* hitPositionY,
double* hitPositionZ,
__int64** changedCellIds,
int* changedCellsSize)
{
const Client::Ray ray(10 * rayOriginX, 10 * rayOriginY, -10 * rayOriginZ, 10 * rayDirectionX, 10 * rayDirectionY, -10 * rayDirectionZ);

const unsigned int size[3] = { sizeX, sizeY, sizeZ };

double hitPosition[3];
VoxelHitInfo hitInfo = vfImpl->vf->rayCast(ray, size, snapToGrid, hitPosition);

std::string xHit = std::to_string(hitPosition[0]);
std::string yHit = std::to_string(hitPosition[1]);
std::string zHit = std::to_string(hitPosition[2]);

xHit = std::to_string(hitPosition[0]);
yHit = std::to_string(hitPosition[1]);
zHit = std::to_string(hitPosition[2]);

if (hitInfo.valid)
{
CGenerator* generator = vfImpl->vf->clipmapView()->generator;
CBlockData* cBlockData = vfImpl->vf->clipmapView()->blockData;

VoxelFarm::Cells changedCells;
TMap<CellId, CCellData::CInstanceEditionVolume> changedVolumes;

VoxelFarm::cursorPaint(
generator,
cBlockData,
hitInfo.cell,

hitInfo.voxel[0],
hitInfo.voxel[1] - 50,
hitInfo.voxel[2],

sizeX,
sizeY,
sizeZ,

cubeBrush,
paintMaterial,
nullptr,
&changedCells,
changedVolumes);

__int64* cellIds = new __int64[changedCells.size()]();
std::set<CellId>::iterator it;
int ind = 0;
for (it = changedCells.begin(); it != changedCells.end(); ++it)
{
__int64 id = (__int64)*it;
cellIds[ind] = id;
ind++;
}

*changedCellIds = cellIds;
*changedCellsSize = changedCells.size();

CClipmapView* clipmap = vfImpl->vf->clipmapView();

clipmap->processModifiedCells(changedCells, false, &changedVolumes);

return true;
}

return false;
}



I think I'm going to try making my own editionCommand that mimics what cursorPaint does.
0 0
rjohnson
Adding a new EditionCommand for CursorPaint ended up working, so I'm all set now, thanks.
0 0
Ericool
Hi rjohnson,
I am glad you were able to create your EditionCommand as this how we currently handle editions in the plugin.
0 0