Exemplo n.º 1
0
void VerifyPrimitivesStructures()
{
	getMainFrame()->launchLoadingDialog("checking primitives structures");
	// Invalidate quad grid
	CWorldEditorDoc *doc = getDocument ();
	if (doc)
	{
		// Begin modifications
		doc->beginModification ();

		string path;
		string errors;
		uint i;
		uint count = doc->getNumDatabaseElement ();
		IPrimitiveEditor::StructureError error = IPrimitiveEditor::NoError;
		for (i=0; i<count; i++)
		{
			getMainFrame()->progressLoadingDialog(float(i+0.0001f)/count);
			if (doc->isEditable (i))
			{
				// Is a primtive ?
				CDatabaseLocatorPointer locator;
				locator.getRoot (i);
				error = (IPrimitiveEditor::StructureError)((sint)VerifyPrimitiveRec (locator, path, errors) | (sint)error);
				//VerifyPrimitiveRec (locator);

				// auto generate missing ID
				doc->resetUniqueID(*(doc->getDatabaseElements(i).RootNode), true);
			}
		}
		// End modifications
		doc->endModification ();

		if (error != IPrimitiveEditor::NoError)
		{
			errors = "Found errors in the tree structure:\n"+errors;
			int first = errors.find_first_not_of ("\n");
			int end = errors.find_first_of ("\n");
			while (first != string::npos)
			{
				nlwarning (errors.substr(first, end-first).c_str());
				first = end;
				end = errors.find_first_of ("\n", end+1);
			}

			theApp.errorMessage (errors.c_str());
		}
	}
	getMainFrame()->terminateLoadingDialog();
}
Exemplo n.º 2
0
void OnModifyPrimitive (CPrimitives &primitives)
{
	// Look for the good database element using the primitives pointer

	CWorldEditorDoc *doc = getDocument ();
	uint i;
	const uint count = doc->getNumDatabaseElement ();
	for (i=0; i<count; i++)
	{
		if (&doc->getDatabaseElements (i) == &primitives)
			break;
	}

	// If found, modify it

	if (i < count)
	{
		doc->modifyDatabase (i);
	}
}