3ds loader fixes

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The MeshBufferNames array has been reallocated to the correct size before such that access to the array should be ok. I don't want to copy all elements to make an empty array cell such that my way should be better in this situation.
Guest

Post by Guest »

According to irrArray.h, direct access only allows reading from the array, if i'm not mistaken..

Code: Select all

	//! Direct access operator
	T& operator [](u32 index)
	{
		_IRR_DEBUG_BREAK_IF(index>=used) // access violation

		return data[index];
	}

	//! Direct access operator
	const T& operator [](u32 index) const
	{
		_IRR_DEBUG_BREAK_IF(index>=used) // access violation

		return data[index];
	}
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, as you can see it resturns a reference to the element. If you don't use the const version (which is only used where const elements are required) you can easily alter the elements.
Guest

Post by Guest »

When you're altering the array elements using [], by reference, does the used variable get increased, because i had to alter the code to use insert() since it was giving me an error here:

Code: Select all

_IRR_DEBUG_BREAK_IF(index>=used) // access violation 
With insert, it seems to increase the used variable so that the index isn't greater or equal to it... and it doesn't give errors? :?
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Sure, that's actually the idea or difference of the two methods. And that's why I use the set_used function to allocate the space. Otherwise you might encounter several copies of the elements. And since I know how large the array will become it's no problem.
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Please note that by changing from emissive to ambient color the strange coloring of room.3ds used in Irrlicht examples shows up again. Please adapt AmbientColor instead of EmissiveColor and everything's working again.
Post Reply