Intermediate Tutorial 4 crash in debug

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
saintnick
Halfling
Posts: 51
Joined: Tue Nov 27, 2018 1:41 am
x 2

Intermediate Tutorial 4 crash in debug

Post by saintnick » Mon Dec 10, 2018 7:54 pm

Ogre Version: 1.11:?:
Operating System: windows 10:?:
Render System: any :?:

I have been working through the tutorials and started getting breakpoints in the last line of the performSelection method while in debug mode. This doesn't happen in release.

Code: Select all

void performSelection(
	const Ogre::Vector2& first,
	const Ogre::Vector2& second)
{
	float left = first.x, right = second.x;
	float top = first.y, bottom = second.y;

	if (left > right)
		swap(left, right);

	if (top > bottom)
		swap(top, bottom);
	
	if ((right - left) * (bottom - top) < 0.0001)
	{
		bottom = top - 0.0001;
		right = left - 0.0001;
	}

	Ogre::Ray topLeft = cam->getCameraToViewportRay(left, top);
	Ogre::Ray topRight = cam->getCameraToViewportRay(right, top);
	Ogre::Ray bottomLeft = cam->getCameraToViewportRay(left, bottom);
	Ogre::Ray bottomRight = cam->getCameraToViewportRay(right, bottom);

	Ogre::Plane frontPlane, topPlane, leftPlane, bottomPlane, rightPlane;

	frontPlane = Ogre::Plane(
		topLeft.getOrigin(),
		topRight.getOrigin(),
		bottomRight.getOrigin());

	topPlane = Ogre::Plane(
		topLeft.getOrigin(),
		topLeft.getPoint(10),
		topRight.getPoint(10));

	leftPlane = Ogre::Plane(
		topLeft.getOrigin(),
		bottomLeft.getPoint(10),
		topLeft.getPoint(10));

	bottomPlane = Ogre::Plane(
		bottomLeft.getOrigin(),
		bottomRight.getPoint(10),
		bottomLeft.getPoint(10));

	rightPlane = Ogre::Plane(
		topRight.getOrigin(),
		topRight.getPoint(10),
		bottomRight.getPoint(10));

	Ogre::PlaneBoundedVolume vol;

	vol.planes.push_back(frontPlane);
	vol.planes.push_back(topPlane);
	vol.planes.push_back(leftPlane);
	vol.planes.push_back(bottomPlane);
	vol.planes.push_back(rightPlane);

	Ogre::PlaneBoundedVolumeList volList;
	volList.push_back(vol);

	mVolQuery->setVolumes(volList);
	mVolQuery->setQueryMask(~SCENE);
	SceneQueryResult result = mVolQuery->execute();

	deselectObjects();

	Ogre::SceneQueryResultMovableList::iterator it;
	for (it = result.movables.begin(); it != result.movables.end(); ++it)
	{
		selectObject(*it);
	}
} // BREAKPOINT
I am pretty sure this started happening after I changed my project settings in Visual Studio. C++ -> Code Generation -> Runtime library from Multithreaded Debug DLL to Multithreaded Debug. Any ideas why this would cause a crash here?
0 x

User avatar
saintnick
Halfling
Posts: 51
Joined: Tue Nov 27, 2018 1:41 am
x 2

Re: Intermediate Tutorial 4 crash in debug

Post by saintnick » Tue Dec 11, 2018 2:48 pm

I can now confirm after starting a new project that changing runtime library from Multi-threaded Debug DLL (/MDd) to the static Multi-threaded Debug (/MTd) causes performSelection to crash.

Debug Assertion failed
Program: etc
File: minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp

Expression: __acrt_first_block == header
0 x

Post Reply