Page 1 of 4 123 ... LastLast
Results 1 to 10 of 40

Thread: Sphere physics

  1. #1
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Sphere physics

    Hi,

    Jordi Valles on PB forum posted very nice 2D demo of kind of sphere physics.
    I ported it to ThinBasic, with pseudo 3D look ( calculations are still 2D ).

    It is pretty computionally intensive.

    How many sphere does your PC manage? I am reaching smoothness limit around 50. This could serve as interesting benchmark for optimizing raw ThinBasic parsing speed

    How to use:
    • Click in the gray box to add spheres
    • Right-Click in the gray box to remove last sphere
    • Watch timing in window title


    Bye,
    Petr
    Attached Images Attached Images
    Attached Files Attached Files
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Sphere physics

    very nice.

    I reached 100 balls at 12 FPS
    A good example to use for testing Core optimization.

    Beautiful
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #3

    Re: Sphere physics

    Nice example. 85 spheres at 12 FPS.

  4. #4
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: Sphere physics

    I filled the box up around 79 balls and when I clicked to drop a ball it would say 14fps and then read 30 fps after that.
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  5. #5

    Re: Sphere physics

    This is an interesting problem for collision detection - its a bit like a sort algorithmn. If you change the inner collision loop to:

    for i = j+1 to nBalls

    instead of:

    for i=1 to nBalls

    then you should double the performance

    at 150 balls it went from 5fps to 10fps on my PC.

    We are still faced with the processing time increasing as the square of the number of balls of course but the number of comparisons has now halved.

  6. #6
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Re: Sphere physics

    Thanks Charles,

    you are right! I can now get 81 spheres at 25FPS.
    Great trick!


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  7. #7

    Re: Sphere physics

    Here is an Oxygenated version. - I have put the inner collision detector loop into assembler and get a steady 34 fps all the way up to 200 balls.

    But see how they quarrel and fight each other when the container gets too full! You would not want to be in there with them.

    PS latest version with slimmer code. (better use of registers)

    Attached Files Attached Files

  8. #8
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Sphere physics

    200 balls at 100 FPS !
    The power of machine code.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  9. #9
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Re: Sphere physics

    Wow ;D

    Here comes slightly modified version, based on Oxygenized one:
    • You can choose 2 sphere detail levels
    • Bigger box
    • More spheres allowed
    • You can spawn objects by holding space and moving mouse



    Petr
    Attached Images Attached Images
    Attached Files Attached Files
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  10. #10
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Sphere physics

    800 speres at 35 FPS here. Big improve. Impressive.

    If it would be possible to develop some TBGL internals on collision detection I think all TBGL scripts would improve a lot.
    But I know it is big job maybe not worth right now.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

Page 1 of 4 123 ... LastLast

Similar Threads

  1. Sphere Texturing
    By zak in forum TBGL General
    Replies: 1
    Last Post: 10-06-2011, 18:40
  2. looking for sphere
    By largo_winch in forum Shout Box Area
    Replies: 7
    Last Post: 17-04-2011, 19:03

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •