Page 1 of 1

MousePick() No work with PB_Any entity

Posted: Tue Aug 12, 2025 12:45 pm
by minimy
(MOVED FROM 3D PROGRAMMING)
Hello, im trying to use PickMouse over 6.21 and return wrong Entity..
Any body can test it and confirm if is a bug?

Return this
CUBE: 2152618004016
Entity clicked: 2147483647

If use a number, not #PB_any, all work fine, but with #PB_any MouseClick() return unknown id (unknown for me) :mrgreen:

How you can see are diferent.
Here the code to test. Thanks.

Code: Select all

InitEngine3D(#PB_Engine3D_DebugLog):InitSprite():InitKeyboard():InitMouse()
OpenWindow(0, 0,0, 1280,720, "Pick test",#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, WindowWidth(0),WindowHeight(0), 0, 0, 0)

CreateCamera(0,0,0,100,100):MoveCamera(0,0,5,-20,#PB_Absolute):CameraLookAt(0,0,5,0):CameraBackColor(0,$332211)
CreateLight(0,$ffffff,3,3,3)

s= CreateSprite(#PB_Any,30,30,#PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(s)):Box(0,0,OutputWidth(),OutputHeight(),$ff0000):StopDrawing()

e= CreateEntity(#PB_Any,MeshID(CreateCube(#PB_Any,1)),MaterialID(CreateMaterial(#PB_Any,#Null,$ff0000)))
Debug "CUBE: "+Str(e)


Repeat
  While WindowEvent():Wend
  ExamineMouse(): ExamineKeyboard()
  
  If MouseButton(#PB_MouseButton_Left)
    If Not lmb
      lmb=1
      e= MousePick(0,MouseX(),MouseY())
      Debug "Entity clicked: "+Str(e)
      If e>-1
      EndIf
    EndIf
  Else
    lmb=0
  EndIf
  
  renderTime= RenderWorld()
  DisplayTransparentSprite(s,MouseX(),MouseY())
  
  FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)

Re: MousePick() No work with PB_Any entity

Posted: Sun Aug 17, 2025 12:19 pm
by infratec
As written in the originam thread:

Strange ...
in PB 6.21 x86 asm backend on Win10 x64 it works.
CUBE: 67700984
Entity clicked: -1
Entity clicked: 67700984
PB6.21 x64 asm backend fails. The returned value is 7FFFFFFF
CUBE: 1D388510E30
Entity clicked: FFFFFFFFFFFFFFFF
Entity clicked: 7FFFFFFF
So it looks like a .l problem when #PB_Any is used.
The maximum positive long value is used as result.