Bug in rayTest?

Nacho
Posts: 31
Joined: Tue Mar 04, 2008 1:41 pm

Bug in rayTest?

Post by Nacho »

Some issue was introduced in rayTest in version 2.70 that produce "flickering" in collision. You can see in VehicleDemo: the wheels are constantly up-down.

I test in my game and I get the same effect: some times the collision is correctly detected but in the next frame, the collision has disapear.

I'm trying to investigate the error but, at this time, I have not found anything. Thanks in advance.
Nacho
Nacho
Posts: 31
Joined: Tue Mar 04, 2008 1:41 pm

Re: Bug in rayTest?

Post by Nacho »

I see the error only happens in Release build. In Debug, ReleaseDoublePrec, DebugDoublePrec, it works correctly.

Nacho
Nacho
Posts: 31
Joined: Tue Mar 04, 2008 1:41 pm

Re: Bug in rayTest?

Post by Nacho »

I have captured a video to show the effect.

Nacho
You do not have the required permissions to view the files attached to this post.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Bug in rayTest?

Post by Erwin Coumans »

The VehicleDemo seems to work fine here in all configurations. Which version of Visual Studio are you using?

Thanks for the feedback, we will try to reproduce and fix it.
Erwin
Nacho
Posts: 31
Joined: Tue Mar 04, 2008 1:41 pm

Re: Bug in rayTest?

Post by Nacho »

I'm using Visual Studio 2005 (8.0). All works fine until I updated to bullet 2.70.

Thanks.
Nacho
Nacho
Posts: 31
Joined: Tue Mar 04, 2008 1:41 pm

Re: Bug in rayTest?

Post by Nacho »

I have detected the problem. To improve preformance, I change Floating Point Model setting (in Configuration Properties -> C/C++ -> Code Generation) from Precise (/fp:precise) to Fast (/fp:fast)

If I do it in libbulletcollision project, the error appear.

The difference between precise and fast in code speed is remarkable.

The codes generated with both options are show below (code from btVoronoiSimplexSolver::updateClosestVectorAndPoints):

Code: Select all

; 200  : 					m_cachedP1 = m_simplexPointsP[0] * m_cachedBC.m_barycentricCoords[0] +
; 201  : 						m_simplexPointsP[1] * m_cachedBC.m_barycentricCoords[1] +
; 202  : 						m_simplexPointsP[2] * m_cachedBC.m_barycentricCoords[2] +
; 203  : 						m_simplexPointsP[3] * m_cachedBC.m_barycentricCoords[3];

           /fp:Precise option                          /fp:Fast option

	fld	DWORD PTR [esi+132]                  fld	DWORD PTR [esi+132]             
	fmul	DWORD PTR [esi+344]                 fmul	DWORD PTR [esi+344]         
	fstp	DWORD PTR $T8072[esp+112]           fld	DWORD PTR [esi+136]             
	fld	DWORD PTR [esi+136]                  fmul	DWORD PTR [esi+344]         
	fmul	DWORD PTR [esi+344]                 fld	DWORD PTR [esi+140]             
	fstp	DWORD PTR $T8072[esp+116]           fmul	DWORD PTR [esi+344]         
	fld	DWORD PTR [esi+140]                  fld	DWORD PTR [esi+116]             
	fmul	DWORD PTR [esi+344]                 fmul	DWORD PTR [esi+340]         
	fstp	DWORD PTR $T8072[esp+120]           fld	DWORD PTR [esi+120]             
	fld	DWORD PTR [esi+116]                  fmul	DWORD PTR [esi+340]         
	fmul	DWORD PTR [esi+340]                 fld	DWORD PTR [esi+124]             
	fstp	DWORD PTR $T8073[esp+112]           fmul	DWORD PTR [esi+340]         
	fld	DWORD PTR [esi+120]                  fld	DWORD PTR [esi+336]             
	fmul	DWORD PTR [esi+340]                 fmul	DWORD PTR [esi+100]         
	fstp	DWORD PTR $T8073[esp+116]           fld	DWORD PTR [esi+104]             
	fld	DWORD PTR [esi+124]                  fmul	DWORD PTR [esi+336]         
	fmul	DWORD PTR [esi+340]                 fstp	DWORD PTR $T8078[esp+80]    
	fstp	DWORD PTR $T8073[esp+120]           fld	DWORD PTR [esi+108]             
	fld	DWORD PTR [esi+336]                  fmul	DWORD PTR [esi+336]         
	fmul	DWORD PTR [esi+100]                 fstp	DWORD PTR $T8078[esp+84]    
	fstp	DWORD PTR $T8074[esp+112]           fld	DWORD PTR [esi+332]             
	fld	DWORD PTR [esi+104]                  fmul	DWORD PTR [esi+84]          
	fmul	DWORD PTR [esi+336]                 fstp	DWORD PTR $T8079[esp+76]    
	fstp	DWORD PTR $T8074[esp+116]           fld	DWORD PTR [esi+88]              
	fld	DWORD PTR [esi+108]                  fmul	DWORD PTR [esi+332]         
	fmul	DWORD PTR [esi+336]                 fstp	DWORD PTR $T8079[esp+80]    
	fstp	DWORD PTR $T8074[esp+120]           fld	DWORD PTR [esi+92]              
	fld	DWORD PTR [esi+332]                  fmul	DWORD PTR [esi+332]         
	fmul	DWORD PTR [esi+84]                  fstp	DWORD PTR $T8079[esp+84]    
	fstp	DWORD PTR $T8075[esp+112]           fadd	DWORD PTR $T8079[esp+76]    
	fld	DWORD PTR [esi+88]                   fstp	DWORD PTR $T8080[esp+76]    
	fmul	DWORD PTR [esi+332]                 fld	DWORD PTR $T8079[esp+80]        
	fstp	DWORD PTR $T8075[esp+116]           fadd	DWORD PTR $T8078[esp+80]    
	fld	DWORD PTR [esi+92]                   fstp	DWORD PTR $T8080[esp+80]    
	fmul	DWORD PTR [esi+332]                 fld	DWORD PTR $T8079[esp+84]        
	fstp	DWORD PTR $T8075[esp+120]           fadd	DWORD PTR $T8078[esp+84]    
	fld	DWORD PTR $T8075[esp+112]            fld	DWORD PTR $T8080[esp+76]        
	fadd	DWORD PTR $T8074[esp+112]           faddp	ST(4), ST(0)                
	fstp	DWORD PTR $T8076[esp+112]           fld	DWORD PTR $T8080[esp+80]        
	fld	DWORD PTR $T8075[esp+116]            faddp	ST(3), ST(0)                
	fadd	DWORD PTR $T8074[esp+116]           faddp	ST(1), ST(0)                
	fstp	DWORD PTR $T8076[esp+116]           fxch	ST(2)                       
	fld	DWORD PTR $T8075[esp+120]            faddp	ST(5), ST(0)                
	fadd	DWORD PTR $T8074[esp+120]           fxch	ST(4)                       
	fstp	DWORD PTR $T8076[esp+120]           fstp	DWORD PTR $T8082[esp+76]    
	fld	DWORD PTR $T8076[esp+112]            mov	ecx, DWORD PTR $T8082[esp+76]   
	fadd	DWORD PTR $T8073[esp+112]           mov	DWORD PTR [esi+244], ecx        
	fstp	DWORD PTR $T8077[esp+112]           fxch	ST(3)                       
	fld	DWORD PTR $T8076[esp+116]            faddp	ST(2), ST(0)                
	fadd	DWORD PTR $T8073[esp+116]           fxch	ST(1)                       
	fstp	DWORD PTR $T8077[esp+116]           fstp	DWORD PTR $T8082[esp+80]    
	fld	DWORD PTR $T8076[esp+120]            mov	edx, DWORD PTR $T8082[esp+80]   
	fadd	DWORD PTR $T8073[esp+120]           mov	DWORD PTR [esi+248], edx        
	fstp	DWORD PTR $T8077[esp+120]           faddp	ST(1), ST(0)                
	fld	DWORD PTR $T8077[esp+112]            fstp	DWORD PTR $T8082[esp+84]    
	fadd	DWORD PTR $T8072[esp+112]           mov	eax, DWORD PTR $T8082[esp+84]   
	fstp	DWORD PTR $T8078[esp+112]           fldz                                
	mov	ecx, DWORD PTR $T8078[esp+112]       mov	DWORD PTR [esi+252], eax        
	fld	DWORD PTR $T8077[esp+116]            fst	DWORD PTR $T8082[esp+88]        
	mov	DWORD PTR [esi+244], ecx             mov	ecx, DWORD PTR $T8082[esp+88]   
	fadd	DWORD PTR $T8072[esp+116]           mov	DWORD PTR [esi+256], ecx        
	fstp	DWORD PTR $T8078[esp+116]   
	mov	edx, DWORD PTR $T8078[esp+116]  
	fld	DWORD PTR $T8077[esp+120]       
	mov	DWORD PTR [esi+248], edx        
	fadd	DWORD PTR $T8072[esp+120]   
	fstp	DWORD PTR $T8078[esp+120]   
	mov	eax, DWORD PTR $T8078[esp+120]  
	fldz                                
	mov	DWORD PTR [esi+252], eax        
	fst	DWORD PTR $T8078[esp+124]       
	mov	ecx, DWORD PTR $T8078[esp+124]  
	mov	DWORD PTR [esi+256], ecx        
the additional FSTP instructions, store the ST0 register into memory which generates slower code.


Nacho
Nacho
Posts: 31
Joined: Tue Mar 04, 2008 1:41 pm

Re: Bug in rayTest?

Post by Nacho »

I change the /fp option in my game, but the error doesn't disappear.

Nacho
Nacho
Posts: 31
Joined: Tue Mar 04, 2008 1:41 pm

Re: Bug in rayTest?

Post by Nacho »

(Sorry by the multi-posting :oops: )


If I remove in btSubSimplexConvexCast.cpp the line 123 (in bullet 2.69 it doesn't exists):

Code: Select all

    //todo: check this normal for validity
    n=v;
the error disappear. When the collision fails, v (in that line) is (0,0,0)

Nacho
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Bug in rayTest?

Post by Erwin Coumans »

Thanks a lot for the great find, it will be fixed in the next release,

Erwin