Syraleaf

Heya,

I was wondering if there should be a meaningful difference between instantiating the various engine objects on the stack versus on the heap? For example, are:

CClipmapView clipmapView(&mat, &gen, &cell, 50000);
CClipmapView* m_pClipmapView{ &mat, &gen, &cell, 50000 }

equivalent code?

0 0
voxelfarmtorres
There is no meaningful difference, just that the compiler will destruct stack objects automatically when they go out of scope.

This is equivalent to switching to pointers:


// create
CClipmapView* clipmapView = new CClipmapView(&mat, &gen, &cell, 50000);

// destroy
delete clipmapView;
1 0
Syraleaf
Alright, so following the pattern in the Demo.ClipmapView, I was able to get a single thread generator working, I then tried the Demo.ClipmapViewMT but when I broke the objects into heap objects with pointers, exceptions started to pop up in the MutexUnion workspace.id lookup. Memory listed as unreadable for the mutable ID array.

Any advice on how to handle this? 😉
0 0
Syraleaf
Oh, and I totally forgot to include this screenshot 😃
There you go, this should help illustrate the situation.

https://media.discordapp.net/attachments/419608039453097985/423573369401901056/unknown.png?width=835&height=465
0 0
voxelfarmtorres
We cannot read the screenshot. It seems the clipmapview object that originated the call is not valid. It could be a non-initialized pointer, or a pointer to an object that was deleted. We do not see this part of your code in the screenshots.
0 0
Syraleaf
Ah, sorry about that. I should have checked the picture before uploading 😅

CContourContext in the right panel has a constructor that takes a pointer to the CClipmapView object on construction, it also instantiates the copy of the CGenerator during construction which seems to work. I agree that it seems that the pointer to the CClipmapView is invalid, thank you, I'll dig deeper!
0 0
Syraleaf
Found the issue!
In my code I was creating a new thread context object after creating the thread, I had assumed this context object would live within the memory space of the tread, but it appears to belong to the parent thread object. As a result, when switching into the thread context, I dropped all references to the generator, threadcontext and celldata pointers.
To solve this I eliminated the context object and moved that code into the inline thread constructor function.
0 0