Giter Club home page Giter Club logo

Comments (7)

cyisfor avatar cyisfor commented on June 24, 2024 1

Thanks taichunmin! I also have since learned that the only mod that does mess up this mod is Geometric Placement, and it just so happens that's what I had trouble with! Your mod works super good, once I set Geometric Placement to be off by default, unless the modifier is pressed.

from todochores.

taichunmin avatar taichunmin commented on June 24, 2024

I think there are two possible reasons for this error:

  1. My Code has bug. (Maybe you can help me to check that?)
  2. The precision problem of float point

Because I want to make plant position always on players top, no matter what angle. So I write some code to calculate the first (x,y) and then add offset. Maybe there are some bug. I am not sure.

from todochores.

cyisfor avatar cyisfor commented on June 24, 2024

I'm closer to finding the problem, but still pretty stumped. I enabled Geometric Placement, and Camera Tweaks so I could get a top-down view, and... it might partially be Geometric Placement's choice of grid density in particular, but...


Plants take up different amounts of space depending on where you plant them.

It's some sort of alignment issue, I'm sure of it, because no matter whether Geometric Placement was set to rotate 45 degrees or not, every item planted took up the same area. But when I tried disabling Geometric Placement and manually placing some grass above that, without a grid, the area each tuft took up varied quite a bit. Maybe it has to be aligned every 10 pixels, or every 20 pixels, or something. (Every 10 pixels according to what reference point?) This mod does already align the things it places on a grid, so the grid just has to be adjusted so it matches up with the game's internal alignment requirements. Then, I bet you could set DEPLOYSPACING_EXTRA to 0!

from todochores.

cyisfor avatar cyisfor commented on June 24, 2024

Also checked components/map.lua, under IsDeployPointClear... It calls TheSim:FindEntities which I'm not sure uses a circular distance, or a square distance... and of course is behind the closed source wall. There's a minimum spacing (DeploySpacingRadius), and also deploy_extra_spacing, though that's only used for a few structures like lava pools. If that's not confusing enough, I think then it checks the square distance from each of those entities, to see if any are too close. So... inside a maximum circle, but then checks the square distance within. So pretty much just the square distance to nearby structures.

But... then... why would the space a thing took up be a different shape at different alignments? Wouldn't it just always be a... square? Maybe I should tweak Geometric Placement to have a ridiculously fine grid, to see if a square shape emerges from that, which doesn't look square from its default grid.

from todochores.

cyisfor avatar cyisfor commented on June 24, 2024

this

Nope, still confused... changing the grid gave me this which indicates that the area something takes up really is a perfect circle, centered in this case on the bottom of the grass tuft, in the exact middle of it horizontally.

Okay, so util.lua has the "distsq" function which isn't the square distance. It's the square of the distance. I was thinking like the "Manhattan distance" but actually the sq just means they're skipping calculating the square root, not that it's square shaped.. So it does measure the real, circular distance from the object. Hmm... is the center of that circle offset from the exact location of the object?

from todochores.

cyisfor avatar cyisfor commented on June 24, 2024

And now it... works perfectly fine. I can't reproduce the bug anymore, and everything plants perfectly close together at the original DEPLOYSPACING_EXTRA = 0.1. I swear sometimes bugs I find disappear just because I look at the code and logically prove that the bugs couldn't have ever existed. Maybe I had a mod, or... something? No other placement mod besides this and Geometric though. Oh well, sorry for making a fuss.

from todochores.

taichunmin avatar taichunmin commented on June 24, 2024

@cyisfor I has updated a newer version which can alter plantable margin in settings.
Please check http://steamcommunity.com/sharedfiles/filedetails/?id=950413860

from todochores.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.