strange problem with vector declaration

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Ghoti
Posts: 288
Joined: Sat Dec 31, 2005 11:06 pm

strange problem with vector declaration

Post by Ghoti »

Hi folks,

i have this vector:

Code: Select all

std&#58;&#58;vector<ObjColFace*>		collisionFaces;	
and the pointer points to :

Code: Select all

typedef struct &#123;	ScePspFVector3	vertices&#91;3&#93;;	&#125; ObjColFace;
if i use the first line, my psp crashes with an address load / inst fetch error using psplink. when i comment it out it all works fine. I do not use the collisionFaces anyway yet in the program (all usage is commented out)

it gives not compiler errors, what am i doing wrong here ?
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

Post by hlide »

*sigh* please don't forget to output the code which uses your std::vector. Nothing can be said here with that very few infos

My hint is that your std::vector has deleted or null pointers because of your blunders or something like.
Ghoti
Posts: 288
Joined: Sat Dec 31, 2005 11:06 pm

Post by Ghoti »

*sigh* please read correct :p , i stated that I do not use the std::vector in my code at all, just putting in the std::vector makes my psp crash when rendering, but in my render sub it does not use the std::vector:

Code: Select all

void Obj&#58;&#58;Render&#40;float x, float y, float z, float turn&#41; &#123;

		//char s&#91;256&#93;;
		//sprintf&#40;s, "Render location&#58; %f, %f, %f and the TURN&#58; %f", x, y, z, turn&#41;;
		//DebugTools&#58;&#58;PrintText&#40;s&#41;;

		matrix_identity&#40;&#40;float*&#41;&world&#41;;


		if &#40;turn != 0&#41; &#123; 
			matrix_identity&#40;&#40;float*&#41;&tmpworld&#41;;
			matrix_rotate&#40;&#40;float*&#41;&tmpworld,0,turn,0&#41;; 
			matrix_multiply&#40;&#40;float*&#41;&world, &#40;float*&#41;&world, &#40;float*&#41;&tmpworld&#41;; 
		&#125;

		matrix_identity&#40;&#40;float*&#41;&tmpworld&#41;;
		matrix_translate&#40;&#40;float*&#41;&tmpworld,x,y,z&#41;;
		matrix_multiply&#40;&#40;float*&#41;&world, &#40;float*&#41;&tmpworld, &#40;float*&#41;&world&#41;; 

		
		sceGuSetMatrix&#40;GU_MODEL,&world&#41;;
		
		sceGuTexMode&#40;GU_PSM_8888, 0 ,0 ,0&#41;;
		sceGuTexFunc&#40;GU_TFX_REPLACE, GU_TCC_RGB&#41;;
		sceGuTexFilter&#40;GU_LINEAR, GU_LINEAR&#41;;
		sceGuTexScale&#40;1.0f, 1.0f&#41;;
		sceGuTexOffset&#40;0.0f, 0.0f&#41;;
		

		int i;


		for &#40;i=0;i<iNumberOfParts;i++&#41;
		&#123;
			sceGuTexImage&#40;0, ObjMeshParts&#91;i&#93;.texture->textureWidth, ObjMeshParts&#91;i&#93;.texture->textureHeight, ObjMeshParts&#91;i&#93;.texture->textureWidth, &#40;void*&#41;ObjMeshParts&#91;i&#93;.texture->data&#41;;
			sceGuDrawArray&#40;GU_TRIANGLES,GU_TEXTURE_32BITF|GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_3D,ObjMeshParts&#91;i&#93;.iFaces*3,0,ObjMeshParts&#91;i&#93;.Vertices&#41;;
		&#125;

		return;
	&#125;;
the std::vector is used to store collisionfaces but is not used at the moment so the only thing i did was adding those two rows in a working application and then it stopped working :s I will look into it more but maybe you have some advice how to find the real error in this or something.

P.S. the sigh and :p were meant as a joke :)[/quote]
ufoz
Posts: 86
Joined: Thu Nov 10, 2005 2:36 am
Location: Tokyo
Contact:

Post by ufoz »

Your bug is probably elsewhere, and adding the extra variable makes it go away. Try tracking down where it crashes with psplink..?
danzel
Posts: 182
Joined: Fri Nov 04, 2005 11:03 pm

Post by danzel »

Alignment of variables would be my guess.
Search the forum for "alignment", most of the results should be useful.

When you add the vector your variables are no longer aligned in memory as they need to be, so when you try use them with something that requires alignment (VFPU for example, which I assume those matrix functions use) it doesn't work.
Post Reply