Jump to content

[SOLVED] DecalMeshes creation crashes with shared Mesh


photo

Recommended Posts

Hello,

we want to share a mesh object with DecalMeshes but it crashes, when we call the setMesh method with the second parameter 0 in Unigine 2.14.1.

We can reproduce this in 2.15 as well.

The documentation on this class is also incomplete for 2.15 and API changes have not been documented.

How can we achieve to alter the mesh object and get the updates to the decal mesh object?

Find a reproducer below.

Thanks

#include "AppWorldLogic.h"
#include <UnigineObjects.h>
#include <UnigineDecals.h>
#include <UnigineMaterials.h>
using namespace Unigine;

// World logic, it takes effect only when the world is loaded.
// These methods are called right after corresponding world script's (UnigineScript) methods.

AppWorldLogic::AppWorldLogic()
{
}

AppWorldLogic::~AppWorldLogic()
{
}

static MeshPtr mesh;
static DecalMeshPtr decalMesh;
static ObjectMeshStaticPtr objMesh;

int AppWorldLogic::init()
{

	// Write here code to be called on world initialization: initialize resources for your world scene during the world start.
		// Write here code to be called on world initialization: initialize resources for your world scene during the world start.
	// create an empty decal mesh
	decalMesh = DecalMesh::create();

	// create a mesh
	mesh = Mesh::create();
	mesh->addSurface();

	mesh->addVertex(Unigine::Math::vec3(0.f, 0.f, 1.f), 0);
	mesh->addVertex(Unigine::Math::vec3(1.f, 0.f, 1.f), 0);
	mesh->addVertex(Unigine::Math::vec3(1.f, 1.f, 1.f), 0);
	mesh->addVertex(Unigine::Math::vec3(0.f, 1.f, 1.f), 0);

	mesh->addIndex(0, 0);
	mesh->addIndex(1, 0);
	mesh->addIndex(2, 0);

	mesh->addIndex(2, 0);
	mesh->addIndex(3, 0);
	mesh->addIndex(0, 0);

	mesh->createTangents();

	mesh->createBounds();
	// copy the mesh into the decal mesh

	decalMesh->setMaterial(Unigine::Materials::findManualMaterial("Unigine::decal_base"));
	decalMesh->setRadius(8.f);
	//decalMesh->setMesh(mesh, 1);// works
	decalMesh->setMesh(mesh, 0); //crashes with nullptr exception in MeshStatic::setMesh Line 129
	return 1;
}

 

Edited by sebastian.vesenmayer
Link to comment

Hi Sebastian,

As for this point:

19 hours ago, sebastian.vesenmayer said:

The documentation on this class is also incomplete for 2.15 and API changes have not been documented.

 

We'll update code snippets in the docs, as there is an old constructor used there (with parameters), other than that the article on the DecalMesh class seems to be up-to-date. Sorry for any inconvenience caused. If there is other "incompleteness" regarding this class, please let us know.

Thank you!

 

  • Thanks 1
Link to comment

Hi Sebastian, 

I see, this was a missing flag in method description, causing a failure of the automatic name converter for constructors in the API docs. Fixed, now Decal constructors should be displayed properly. 

Thanks for reporting!

 

Link to comment
  • silent changed the title to [SOLVED] DecalMeshes creation crashes with shared Mesh
×
×
  • Create New...