1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Optimising AABB

Discussion in 'Contributing & RFCs' started by XenialDan, Sep 9, 2018.

  1. XenialDan

    XenialDan Baby Zombie

    Messages:
    141
    GitHub:
    thebigsmilexd
    AABB is pretty poorly coded/usable

    I coded myself classes to extend it. In example:

    getSize: return a v3 with the size

    minX/Y/Z: v3 min

    maxX/Y/Z: v3 max

    Setting min/max positions will actually set min and max positions.. currently maxY can be 10 and minY can be 40.. without any checks if it is true that minY is actually smaller

    getCenter/getMiddle: v3 center

    Maybe you also got ideas how to improve this (sorry for the poorly written article)
     
  2. dktapps

    dktapps Administrator Staff Member PMMP Team

    Messages:
    774
    GitHub:
    dktapps
    don't forget that AxisAlignedBB is heavily used in hot paths, so any change you make to already-used functionality could have widespread effects on performance.
     
  3. XenialDan

    XenialDan Baby Zombie

    Messages:
    141
    GitHub:
    thebigsmilexd
    Adding stuff for improving the class and mire functions will not create any impact on performance. A person once said: "Do not care about microoptimisations in already heavy projects"

    Also, these things would bring more API to developers so not every plugin has to define these functions themself (which would be less performant than api functions.)
     
  4. dktapps

    dktapps Administrator Staff Member PMMP Team

    Messages:
    774
    GitHub:
    dktapps
    I said changes to already-used functionality. And the opposite is also true: mess with the wrong thing and it could have consequences far more costly than you know.

    Adding new API methods seems reasonable, but be careful changing things that already exist.
     
  5. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    [​IMG]
     
  6. XenialDan

    XenialDan Baby Zombie

    Messages:
    141
    GitHub:
    thebigsmilexd
    The recent change (throwing errors when constructing with bigger min than max) honestly sucks. Instead the class should fix the order itself but throw a warning.
    Plenty of plugins, for example a commonly used one named "MyPlot" break because errors are thrown

    For reference a MCBE compatible c++ header
    https://github.com/ryanterry131/PocketPower/blob/master/jni/mcpe/world/phys/AABB.h
    The advantages of using vec3 is that those already implement funtions to move them (just add to both vec3 and tada, the aabb moved) and more
     
  7. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    [​IMG]
    What errors??
     
  8. XenialDan

    XenialDan Baby Zombie

    Messages:
    141
    GitHub:
    thebigsmilexd
    Max:
    Sure? This error will be shown when i clear/reset a plot in MyPlot:

    09:05:18[Server thread/CRITICAL]: InvalidArgumentException: "minX -213 is larger than maxX -277" (EXCEPTION) in "vendor/pocketmine/math/src/AxisAlignedBB" at line 47

    09:05:18[Server thread/DEBUG]: #0 vendor/pocketmine/math/src/AxisAlignedBB(42): pocketmine\math\AxisAlignedBB->setBounds(double -213, double 0, double 0, double -277, double 256, double 64
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.