pointer.cpp

Sat, 16 Mar 2013 16:59:16 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Sat, 16 Mar 2013 16:59:16 +0200
changeset 21
9aebaaafa5da
parent 19
6c5977e43e73
permissions
-rw-r--r--

Added split-quads-to-triangles function

#include "pointer.h"

vector<objPointer*> g_pObjectPointers;

void objPointer::replacePointers (LDObject* old, LDObject* repl) {
	for (ulong i = 0; i < g_pObjectPointers.size(); ++i) {
		objPointer* ptrptr = g_pObjectPointers[i];
		
		if ((*ptrptr).ptr == old)
			(*ptrptr).ptr = repl;
	}
}

objPointer::~objPointer () {
	
}

objPointer::objPointer () {
	ptr = nullptr;
}

objPointer::objPointer (LDObject* _ptr) {
	ptr = _ptr;
}

void objPointer::serialize () {
	g_pObjectPointers.push_back (this);
}

void objPointer::unSerialize () {
	for (ulong i = 0; i < g_pObjectPointers.size(); ++i)
		if (g_pObjectPointers[i] == this)
			g_pObjectPointers.erase (g_pObjectPointers.begin() + i);
}

void objPointer::deleteObj (LDObject* obj) {
	replacePointers (obj, nullptr);
	delete obj;
}

mercurial