Detection of multi-block structures in which a certain location is located

Discussion in 'Plugin Development' started by Nik De Kur, Feb 10, 2024.

  1. Offline

    Nik De Kur

    Hello! I'm faced with a difficult problem and can't think of a solution. I have a lot of multi-block structures in my world, I need a data structure/algorithm that can, given a Location object, find the multi-block structures that contain it. Structures can be of any shape - spheres, cuboids, cylinders. Linear search is not suitable due to the presence of a large number of multi-block structures.

    Thank you in advance for your cooperation!
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    Nik De Kur

    No, I'm trying to discover them as I play. Let’s say, in the mechanics of a skill, when a skill object moves, multi-block structures are searched for in a new location and operations occur with them.
     
  4. Offline

    timtower Administrator Administrator Moderator

    What kind of structures are you looking for then?
     
  5. Offline

    Nik De Kur

    My custom multi-block structures. Let's say a stone structure of 5 by 5 by 5 blocks. I need to create a method that will return all structures within the boundaries of which this block is located.
    Structures are registered when the plugin is loaded and are stored as com.sk89q.worldedit.regions.Region objects.

    If my stone structure is located at coordinates (131, 151, 105) - (127, 155, 109), then if I pass the location (128, 153, 107) to the method, which in this situation is inside my stone structure, then I should get back an object of this very structure (I have an object representing structures).
     
  6. Offline

    timtower Administrator Administrator Moderator

    That sounds like you have the structures in the world already on world gen, is that correct?
     
  7. Offline

    Nik De Kur

    Structures are loaded from configuration files when the plugin is enabled, immediately placed and added to a simple register (List). I want to make an addition to some other data structure that will allow me to implement a quick search. I initially used Octree, but then it became necessary to switch from cuboid regions to freeform regions, which made my Octree mechanism, which uses minVector and maxVector, no longer suitable for spheres and cylinders.
     

Share This Page