ExamineWorldCollisions() causes shaky objects.

Everything related to 3D programming
Henry00
User
User
Posts: 88
Joined: Thu Jul 12, 2012 7:00 pm
Location: Germany
Contact:

ExamineWorldCollisions() causes shaky objects.

Post by Henry00 »

Hello!

I am unable to reproduce this properly in an example script but calling ExamineWorldCollisions() each frame is causing my entities to sleep less and slide / jump more violently. Without a call to this function they just stop and sleep normally as you'd expect. Can anyone confirm this behavior?

Thanks!
User avatar
DK_PETER
Addict
Addict
Posts: 904
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: ExamineWorldCollisions() causes shaky objects.

Post by DK_PETER »

@Henry00
Sorry, I can't reproduce the shaky behaviour.

Edit: Made a small nonsense example...It works fine.
You might want to check your parameters..mass, friction, WorldGravity(), etc....

Code: Select all

InitEngine3D()
InitSprite()
InitKeyboard()

Structure _obj
  id.i
  ms.i
  ma.i
  tx.i
EndStructure

Global Ball1._obj, Ball2._obj, plane._obj

OpenWindow(0, 0, 0, 1024, 768, "Collision",#PB_Window_ScreenCentered | #PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(0), 0, 0, 1024, 768, #False, 0, 0, #PB_Screen_NoSynchronization)
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 0, 1, 10)


With plane
  \ms = CreatePlane(#PB_Any, 20, 20, 1, 1, 1, 1)
  \tx = CreateTexture(#PB_Any, 256, 256)
  StartDrawing(TextureOutput(\tx))
  Box(0, 0, 256, 256, $04F306)
  StopDrawing()
  \ma = CreateMaterial(#PB_Any, TextureID(\tx))
  \id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), -1, -2, 0)
  RotateEntity(\id, 0,0,0)
  EntityPhysicBody(\id, #PB_Entity_StaticBody, 1, 10.30, 50)
EndWith

With Ball1
  \ms = CreateSphere(#PB_Any, 0.1, 10, 10)
  \tx = CreateTexture(#PB_Any, 256, 256)
  StartDrawing(TextureOutput(\tx))
  Box(0, 0, 256, 256, $046DAF)
  StopDrawing()
  \ma = CreateMaterial(#PB_Any, TextureID(\tx))
  \id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 0, 1, 0) 
  EntityPhysicBody(\id, #PB_Entity_SphereBody, 0.1, 0.04, 10)
EndWith

With Ball2
  \ms = CreateSphere(#PB_Any, 0.1, 10, 10)
  \tx = CreateTexture(#PB_Any, 256, 256)
  StartDrawing(TextureOutput(\tx))
  Box(0, 0, 256, 256, $0411D3)
  StopDrawing()
  \ma = CreateMaterial(#PB_Any, TextureID(\tx))
  \id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 0, 1, 0) 
  EntityPhysicBody(\id, #PB_Entity_SphereBody, 0.1, 0.04, 10) 
EndWith

Repeat
  
  Repeat
    ev = WindowEvent()
  Until ev = 0
  
  ExamineKeyboard()
  
  If KeyboardReleased(#PB_Key_Space)
      MoveEntity(ball1\id, 0, 3, 0, #PB_Absolute)  
      MoveEntity(ball2\id, 0, 3, 0, #PB_Absolute)
  EndIf
    
  If KeyboardPushed(#PB_Key_Left)
    ApplyEntityForce(ball1\id, -1, 0, 0, -2, 2, 0)
  EndIf

  If KeyboardPushed(#PB_Key_Right)
    ApplyEntityForce(ball2\id, 1, 0, 0, 2, 2, 0)
  EndIf
  
  ret = ExamineWorldCollisions(#True)

  If ret > 0     
    Debug "collision detected"
  EndIf
  
  RenderWorld()
  
  FlipBuffers()
  
Until KeyboardPushed(#PB_Key_Escape)
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
Post Reply