On 25/09/2017 at 16:42, xxxxxxxx wrote:
Cinema 4D Version: R18
Platform: Windows ;
Language(s) : C++ ;
I have found an unpleasant thing.
R18 crashes if I compute normals = pobj->CreatePhongNormals(); when running on a background thread.
There was document clone (via GetClone), then started a background thread, then called doc_clone->ExecutePasses on the new thread. Then parsed the cloned doc and reached the call normals = pobj->CreatePhongNormals(); And this call for normals calculations crashes Cinema if the object has more than 8192 polygons (the number is something like that). E.g. create a sphere with 128 segments and it will crash. If there are say 120 segments on the sphere it doesn't crash.
If I comment the line with "normals = pobj->CreatePhongNormals();" then there is no crash. And e.g. there is also no crash on R17 for the same code. Without this background thread (running on Main thread) everything is fine on R18 too.
It seems like there is no enogh memory inside CreatePhongNormals for objects with more than ~8K polygons. How to fix that?
I can also add that the background thead where these thing is running is std::thread. Haven't yet tried with C4DThread. Does that make any sense?
Please help me to fix the issue.
On 26/09/2017 at 01:39, xxxxxxxx wrote:
we advise to use C4DThread instead of std::thread. Does the issue also occur using C4DThread and under R19? You find information on C4DThread in the C4DThread Manual.
Using C4DThread and R19 I could not reproduce any issue with CreatePhongNormals(). This is the code I used:
class PhongThread : public C4DThread
BaseDocument* _copy = nullptr;
void SetDoc(BaseDocument* orignal)
C4DAtom* copy = orignal->GetClone(COPYFLAGS_0, nullptr);
_copy = static_cast<BaseDocument*>(copy);
_copy->ExecutePasses(this->Get(), true, true, true, BUILDFLAGS_EXTERNALRENDERER);
BaseObject* object = _copy->GetFirstObject();
if (object && object->IsInstanceOf(Opolygon))
PolygonObject* poly = ToPoly(object);
Vector32* normals = poly->CreatePhongNormals();
const Char* GetThreadName()
Does this code reproduce the issue for you? If not, could you post some code to reproduce the issue?
On 26/09/2017 at 03:09, xxxxxxxx wrote:
I will test it now on R18. Thanks for the sample. It seems that there is something (probably) with per-thread allocator. Strange thing is that ExecutePasses (which is more complex with caches builder) is working in such a std::thread and a simpler thing like CreatePhongNormals not. Will test C4DThread and minimize the code using std::thread for your diagnostics. Btw R18 was R18.11 then updaed to R18.57 and result was the same crash.
Don't yet have R19, can't test on it.
On 26/09/2017 at 05:51, xxxxxxxx wrote:
With direct replacement from std::thread to C4DThread it works without problems now!