Rust without rust
Rust without rust
  • Видео 15
  • Просмотров 81 693
Algorithms: Randomly Placing a Point Inside a Circle
#algorithms #maths #geometry #trigonometry #gamedev #coding #leetcodeproblems
Randomly placing a point inside a circle is a fairly simple, beautiful and clean problem. In this video, we're going to talk about it.
Demonstration link on GitHub: kul-sudo/circles
0:00 Introduction
0:19 1st Approach
1:00 2nd Approach
Просмотров: 1 284

Видео

Dynamic Mazes Demonstration
Просмотров 370Месяц назад
#programming #algorithms In the last video, I showed 2 dynamic maze algorithms. Today, let's take a look at a dynamic mazes demonstration. Music: Noah Barger - Ballad The demonstration: kul-sudo/maze
Dynamic Mazes: Algorithms You've Never Seen
Просмотров 837Месяц назад
#programming #algorithms Maze generation is a fairly popular topic in the field of algorithms. Today, let's explore dynamic maze algorithms you haven't seen. Sound at the end: Noah Barger - Piano Tune.mp3 The demonstration: kul-sudo/maze 0:00 Basics and Terminology 0:40 1st Approach 1:53 2nd Approach
Evolution Simulator: It's More Like Earth
Просмотров 1,3 тыс.2 месяца назад
#gamedev #gamedev #2d #coding The evolution simulator I've made has always had few similarities with real-life evolution and too many abstractions. Now that carnivores, omnivores, and herbivores have been added, it's more like Earth. Sound at the end: Noah Barger - Piano Tune.mp3 The evolution simulator: kul-sudo/eportal
Quadtrees: Blazingly Fast Collision Detection
Просмотров 45 тыс.2 месяца назад
#gamedev #gamedevelopment #2d #coding Detecting collisions can be done by going through each object for each object, but that'd be fairly slow. A beautiful and efficient way is using quadtrees. Sound at the end: Noah Barger - Piano Tune.mp3 Demonstration link on GitHub: kul-sudo/quadtrees
Spatial Hashing: Instantly Finding the Closest Neighbor
Просмотров 25 тыс.3 месяца назад
#gamedev #gamedev #2d #coding There's a fairly easy way of finding the closest neighbor among thousands and thousands of objects almost instantly. Today I'll show it. Demonstration link on GitHub: kul-sudo/spatial_hashing
Evolution Simulator: Analysis
Просмотров 2803 месяца назад
#opensource #github #rustlang #programming #coding In the previous video I demonstrated an evolution simulator I was working on. In this video I'll analyse the overall evolution process and try to explain what happens for what reason. And here's the project itself on GitHub: kul-sudo/eportal
I Built an Evolution Simulator
Просмотров 1,2 тыс.4 месяца назад
#opensource #github #rustlang #programming #coding In this video I'll demonstrate an evolution project I'm working on. The great song at the end: Noah Barger - it's been a bit. And here's the project itself on GitHub: kul-sudo/eportal
Rust Vectors: How do they work?
Просмотров 3374 месяца назад
#rustlang #programming #coding #codingtutorial I think many people really misuse vectors, so in this video I'll show how they're implemented and their cons.
Enums in Rust: Almost Too Good?
Просмотров 5914 месяца назад
#rustlang #programming #enums #coding #codingtutorial I think many people heavily underuse enums in Rust, so in this video I'll talk about them.
Rust Tips to Boost your Skill
Просмотров 1,6 тыс.4 месяца назад
#rustlang #programming #coding #codingtutorial Today I'll share with you a few Rust tips that are important to know. I hope you enjoy the video!
Threads in Rust: Parallel Computing
Просмотров 2,2 тыс.5 месяцев назад
#rustlang #programming #async #coding #codingtutorial I think many people greatly underrate threads in Rust, so in this video I'll talk about them.
How to disarm Rust
Просмотров 3095 месяцев назад
#rustlang #programming #coding #codingtutorial Hello everyone. I decided to make a video about using `unsafe` in Rust, because most people don't seem to know the power of it and and that it isn't really a crime.
Rust for rookies
Просмотров 3075 месяцев назад
#rustlang #programming #coding #codingtutorial Hello everyone. Recently I've noticed that a lot of people want to learn Rust but don't know what it even is. In this video, I tried to explain that in simple worlds. I'm also working on integrating a donation system into my channel, so I'll probably do it by the next video.
The easiest Rust borrowing guide
Просмотров 5575 месяцев назад
#rustlang #programming #coding #codingtutorial Hey everyone. In this video, I tried to as simply as possible explain borrowing in Rust. I was watching a lot of videos about it when I was learning Rust and was never able to understand it, so I hope this video is especially helpful for beginners. Enjoy!

Комментарии

  • @basiliotornado
    @basiliotornado 8 дней назад

    0:26 i see 2 balls intersecting 👀 Nice video, I'll have to try this out as a project soon.

    • @rustwithoutrust
      @rustwithoutrust 7 дней назад

      Yeah, that was a glitch I've fixed already lol

  • @Nazar0360
    @Nazar0360 8 дней назад

    Do you have a proof, why the last method works? I'm a math guy, so I'd like to know

    • @rustwithoutrust
      @rustwithoutrust 7 дней назад

      I interpret that formula intuitively, but this proof should suffice: *Step 1:* The function determines the chance that a circle with the radius r is within a circle with the radius R. F(r) = (πr²)/​(πR²)=r²/R² *Step 2:* ζ ∈ [0, 1] F(r) = ζ *Step 3:* r²/R² = ζ → r = R√ζ

  • @deepfriedlettuce.
    @deepfriedlettuce. 8 дней назад

    hmm very cool but I don't get the last method

    • @rustwithoutrust
      @rustwithoutrust 8 дней назад

      I didn't want the video to be engulfed by math; instead, I wanted to make it intuitively clear. Think of it this way: picking a random ring (radius) and then picking a random point on the ring. What happens next is an intuitive solution to the points grouping around the center. If you want a remote explanation of this intuitive solution, it's a way to prevent values close to the boundaries of random(0, 1). For instance, sqrt(0.01) is 0.1, which makes the position noticably closer to the middle ring.

  • @vliedtke
    @vliedtke 9 дней назад

    Do you have a benchmark for both methods?

    • @rustwithoutrust
      @rustwithoutrust 8 дней назад

      The second one's more consistent, but if the first one gets lucky and doesn't miss the circle, it'll be faster.

  • @three-four-seven
    @three-four-seven 9 дней назад

    Could also use max(rand, rand)*max_r

    • @maroonshaded
      @maroonshaded 9 дней назад

      Yeah I thought of that too because of a video I watched a few days ago on that topic!

    • @rustwithoutrust
      @rustwithoutrust 8 дней назад

      If rand here is a macro for random(0, 1), then I could see it giving a rather unnaturally higher average. Perhaps you have an idea on why that'd be helpful, no joking.

    • @henry6398
      @henry6398 8 дней назад

      ​@@rustwithoutrustsqrt(rand) and max(rand,rand) have the exact same probability distribution. i don't know if there's a reason to use one over the other in code, though.

  • @cobbcoding
    @cobbcoding 10 дней назад

    never let bro work at a pizza place 😭

  • @zaorincito
    @zaorincito Месяц назад

    Nice

  • @alliesakat
    @alliesakat Месяц назад

    this feels christmasy somehow lol

    • @rustwithoutrust
      @rustwithoutrust Месяц назад

      @@alliesakat Because Noah Barger's music always improves whatever it touches

  • @cobbcoding
    @cobbcoding Месяц назад

    ok this is epic how the video syncs with the music at times, great editing

    • @rustwithoutrust
      @rustwithoutrust Месяц назад

      Yeeeeah! Big W to Noah Barger for the soundtrack.

  • @agusavior_channel
    @agusavior_channel Месяц назад

    Very nice

  • @lanata64
    @lanata64 Месяц назад

    what kind of collision detection are you using? just checking if two bodies overlap/touch, or is it something else?

    • @rustwithoutrust
      @rustwithoutrust Месяц назад

      @@lanata64 Yes, whether they overlap.

    • @lanata64
      @lanata64 Месяц назад

      @@rustwithoutrust i wonder if it'd be faster to do some sort of continuous/'event based' CD, and then lower the tick rate.

    • @rustwithoutrust
      @rustwithoutrust Месяц назад

      @@lanata64 Well, if an object moves, it can always potentially collide, so this is the most natural approach to check for a collision on every position change.

    • @lanata64
      @lanata64 Месяц назад

      @@rustwithoutrust well yeah, but i was wondering if a continuous cd method that doesn't use 'overlap-checking' in the same way might be faster if you can lower the tick rate (since the max tolerable movement per tick could be far higher)

  • @omadalosso
    @omadalosso Месяц назад

    It could be expanded to use octrees for 3D environments :) I've implemented this during a research internship.

  • @cobbcoding
    @cobbcoding Месяц назад

    very insightful video

  • @leggysoft
    @leggysoft Месяц назад

    One huge optimization is making your grid scale suit it's purpose. What's the smallest and largest item? Some game engines have a stroke with many large or small items.

  • @mjdev-i1p
    @mjdev-i1p Месяц назад

    This has nothing to do with hashing ... dude your chat-gpt hallucinated

  • @mateusvmv
    @mateusvmv Месяц назад

    Cool! I'd like to hear what you think about implementing QuadTrees implicitly using BTrees and Z-Order curves, if you've tested it or have a benchmark, the implementation might be much simpler and simplicity is definitely a plus! What happens is that each two bits in the Z-Order key will represent a position in a layer of the QuadTree. So you can use a modified QuadTree function (which generates the next z order index within a range) and iterate over a BTree, doing a new range search with the next valid index when the iterator falls outside of our query rectangle. It does improve data locality in memory and reduces allocations, and the branching factor of a BTree (rust uses 11) is better than that of a QuadTree (4), but it restarts the search from the root for every quadrant. I don't have a benchmark in hand, unfortunately.

    • @rustwithoutrust
      @rustwithoutrust Месяц назад

      Hey, I'll take a look at it and maybe do a video.

    • @mateusvmv
      @mateusvmv Месяц назад

      @@rustwithoutrust The k-dimensional data structures, like space filling indexes, can do queries for things that are not points: Rectangles (a, b, c, d) and (e, f, g, h) intersect if (0, 0, a, b) <= (e, f, g, h) <= (c, d, inf, inf) The collision problem which is hard in 2D becomes a simple range query in 4D space

  • @gokusaiyan1128
    @gokusaiyan1128 Месяц назад

    Bro, how would you recommend to learn rust, I have tried plenty of times but I just can't get over it's syntax. I find golang syntax easy and works for me.

    • @rustwithoutrust
      @rustwithoutrust Месяц назад

      I think overcoming syntax mistakes takes making a couple of relatively big projects. What you could have even bigger problems with is the borrow checker, but most of the time fixing errors related to it includes changing the structure or the logic for it to be memory-safe; that also takes a couple of projects to overcome. But you aren't forced to use Rust, so if Go works for you, keep in mind it's garbage-collected, which is its disadvantage. The way I see it, if you need a company-level codebase that never segfaults and is easy to maintain for years, Rust is your option.

    • @gokusaiyan1128
      @gokusaiyan1128 Месяц назад

      @@rustwithoutrust so what would you recommend ? I start with a rust book and build project after that :) ?

    • @rustwithoutrust
      @rustwithoutrust Месяц назад

      Yes, I recommend to read the official book and go through a few unofficial ones. But ultimately, you'll learn the most from building a project.

    • @gokusaiyan1128
      @gokusaiyan1128 Месяц назад

      @@rustwithoutrust thank u so much !!

  • @coolkattcoder
    @coolkattcoder Месяц назад

    Awesome!

  • @lel7531
    @lel7531 Месяц назад

    Cool video thank you

  • @gillall4828
    @gillall4828 2 месяца назад

    YYYY

  • @DustinKrejci
    @DustinKrejci 2 месяца назад

    where can I find the code for this project?

  • @skylark.kraken
    @skylark.kraken 2 месяца назад

    Also if you just want which one is closer and don't need the specific distance you don't need to use a square root, just compare `dx^2+dy^2` as you'll just be comparing `r^2` which is fine - if you do need the distance you can then sqrt the `r^2` of the closest neighbour after. However, it doesn't really apply to this situation where you have few collisions if the size of cells are correct, the demonstration repo uses `.distance` which is far cleaner; just wanted to point it out as I do see a lot of people using sqrts for things where they aren't necessary, if you don't have too many entities to check you may be able to get away with not dealing with space partitioning and instead just remove square roots.

  • @cobbcoding
    @cobbcoding 2 месяца назад

    thumbnail is literally me when seeing a Rust without rust upload

  • @caiodallecio
    @caiodallecio 2 месяца назад

    Interval trees

  • @nathanfranck5822
    @nathanfranck5822 2 месяца назад

    6 years ago I did a physics collision system using quadtrees where I generified the node to have any number of leaves. Turns out adding way more leaves into a single node was tonnes faster, and reducing depth. I ended up with an optimal solution having just a depth of 2: chunks and cells. So my recommendation to have a super fast grid of bins would be to just have a hashmap of chunk coordinates to chunks, where each chunk is an array of cells. Its super simple to implement and very very fast, while retaining a lot of the space saving, since empty chunks can be removed from the hashmap.

    • @NickCombs
      @NickCombs 2 месяца назад

      That's cool. Thanks for sharing

    • @fdsphone6854
      @fdsphone6854 20 дней назад

      this I understand. I did not get the quad tree. not the creators fault. im slow and not too bright.

  • @PerriPaprikash
    @PerriPaprikash 2 месяца назад

    probably would have been better to do this in either C++ or Python, as the Rust code is clearly not comprehensible.

  • @superfliping
    @superfliping 2 месяца назад

    Amazing thank you

  • @BenjaminRosseaux
    @BenjaminRosseaux 2 месяца назад

    As a physics engine developer, I want to point out that while QuadTrees and Octrees are often praised for their performance, they aren't always ideal for certain tasks, especially in physics engines that require advanced features like raycasting or shape/sphere casting. These data structures struggle with irregularly sized objects that exceed the size of a cell, and there's significant overhead when performing raycasting because of the DDA-style stepping required through the Quadtree or Octree cells. Physics engines like Bullet, Box2D, Jolt, and my own full-featured 3D physics engine KRAFT (written in Object Pascal) all use dynamic, self-balancing AABB BVH (Axis-Aligned Bounding Box Bounding Volume Hierarchies) trees for optimal performance. PhysX, on the other hand, relies on Sweep and Prune (S&P) for broad-phase pair management and also uses AABB BVH trees for efficient raycasting.

    • @rustwithoutrust
      @rustwithoutrust 2 месяца назад

      do you think quadtrees are optimal for those 2d collision demonstrations?

    • @BenjaminRosseaux
      @BenjaminRosseaux 2 месяца назад

      ​@@rustwithoutrust For 2D and 3D collision demos with almost similarly sized objects (for example particles), QuadTrees and Octrees are pretty solid and get the job done nicely 😊. They’re a good choice when everything’s about the same size, but for more complex physics, raycasting or different-sized objects, other approaches might work better 😉.

    • @stefanalecu9532
      @stefanalecu9532 2 месяца назад

      Hey, didn't expect to see you here! I wanted to thank you for your work on Kraft, it's been a pleasure to go through the source code and learn a thing or two! Why haven't you split up the source, since kraft.pas is a really long file? Are you aiming for having a unit-only physics engine?

    • @brickmasterhunt4561
      @brickmasterhunt4561 2 месяца назад

      @@BenjaminRosseaux Would there be a way to dynamically effect the radius of each object in the quad tree?

    • @BenjaminRosseaux
      @BenjaminRosseaux 2 месяца назад

      @@brickmasterhunt4561 Although it is possible to have objects with different radii in a Quadtree or Octree, this approach is not very optimal. The main issue is that objects would have to overlap into neighboring cells based on their new radius, complicating the structure. Additionally, neighboring cells would need to be constantly checked and updated based on the object's radius, increasing complexity and potentially leading to an O(n²) runtime in the worst case. This becomes particularly inefficient as the number of objects grows. Moreover, this approach introduces inefficiencies since Quadtrees and Octrees are designed more primarily for fixed bounding volumes, uniform element sizes, or otherwise purely static runtime lookups. Different radii and different object sizes (especially those larger than a Quadtree or Octree leaf cell) would negate the spatial partitioning benefits in the dynamic usage case. Alternatives like dynamic self-balancing AABB BVH/BIH trees or even loose Quadtrees/Octrees can handle varying object sizes and radii more efficiently.

  • @a.lollipop
    @a.lollipop 2 месяца назад

    this will be a great channel to follow as im making my own game engine haha, great content! I never thought of this approach, this is very nice :3

  • @Stagnated541
    @Stagnated541 2 месяца назад

    Can you implement this on scratch so I can see this more clearly? When working on quad-trees, I noticed that it is impossible to make it work when you have a dense map of small and big objects I just don't understand 2:02 to the end

    • @rustwithoutrust
      @rustwithoutrust 2 месяца назад

      You can check out kul-sudo/quadtrees on GitHub for the implementation

  • @webkinskid
    @webkinskid 2 месяца назад

    Does blazingly fast refer to the algorithm or the video??

  • @ClokworkGremlin
    @ClokworkGremlin 2 месяца назад

    [Edit] Correction: the number in the corner is processor time, not point count, as per 1:30 [Original post]1:35 FOUL! Your brute force implementation used 500,000 points, but your quadtree implementation used only 50,000. It's easy to get a massive speedup when you reduce the test size by 90%.

    • @rustwithoutrust
      @rustwithoutrust 2 месяца назад

      Excuse me, what? That is simply a lie without any base under it. Moreover, you can run it all yourself and see that difference.

    • @ClokworkGremlin
      @ClokworkGremlin 2 месяца назад

      @@rustwithoutrust I assumed the numbers on the corner of the screen are the particle counts. Is that not what they are?

    • @rustwithoutrust
      @rustwithoutrust 2 месяца назад

      It's said it's the processor time

    • @cobbcoding
      @cobbcoding 2 месяца назад

      @@ClokworkGremlin you should maybe watch the video you're commenting on? He literally says what the number is in the video.

    • @ClokworkGremlin
      @ClokworkGremlin 2 месяца назад

      @@rustwithoutrust Ah. I missed where that was mentioned at 1:30-1:31. How many points were in this test sample? I've found the overall gain varies wildly based on the density of points being tested. At 1,000 points, varying from 1 and 5 units in radius, across a 1,000x1,000 unit square, I have both a sparse grid-based system and a quadtree based system that run close to 20x as fast as the brute force solution. At 10,000 or more points under the same conditions, the brute force solution is no longer viable due to both time and memory constraints. Working on a bounds sorting solution now, to see how it compares. The dense grid works about the same as the sparse grid, but takes up considerably more memory.

  • @fizipcfx
    @fizipcfx 2 месяца назад

    what is that weird effect where it looks like text is jittering

    • @rustwithoutrust
      @rustwithoutrust 2 месяца назад

      blur

    • @leeroyjenkins0
      @leeroyjenkins0 2 месяца назад

      ​@@rustwithoutrustvery avant-garde 🧐

    • @rustwithoutrust
      @rustwithoutrust 2 месяца назад

      @leeroyjenkins0 Yeah, have you seen the subtitles? I've been grinding French and decided it'd be good to make French subtitles. If that's what you mean.

    • @leeroyjenkins0
      @leeroyjenkins0 2 месяца назад

      @rustwithoutrust oh! 😂 No sorry I just picked an artsy word for fun Best of luck with that! It really is a crazy language..! I happen to speak it fluently, it's very understandable! Other than working on common idioms. Some notes as an aside "here's the point" would probably be "en résumé" in this context, and often point would be more "argument" than "point" even if it's usually understood, especially in Canada I'd guess. "Move into the cell" would be more "Dans" than "dedans" if you specify the object of "what is it moving into" you don't use the "de" as that's what "de" is referring to. "Utile pour des collisions" would be more "utile pour les collisions" mostly because you're talking about "collisions" as a concept. Small details like that. Also, for this type of video you'd probably address the audience as a plurality so sticking more towards "vous" (not necessarily as the polite form, just addressing all viewers at once), but that's nuanced by the target audience, including the fact that "tu" is more prevalent in french Canadian. That aside neat bite-sized video ^^ Cheers!

    • @rustwithoutrust
      @rustwithoutrust 2 месяца назад

      I'll probably make French subtitles for all my videos, because that could be good practice for me. Moreover, I'm soon starting to read a book in French that'll definitely boost me and give me more understanding of those little things!

  • @SmirkInvestigator
    @SmirkInvestigator 2 месяца назад

    Wake me up when it’s oct trees

    • @rustwithoutrust
      @rustwithoutrust 2 месяца назад

      ok, no need for an alarm clock

    • @SmirkInvestigator
      @SmirkInvestigator 2 месяца назад

      @@rustwithoutrust lol. Definitely face palmed when reflecting on my own novice attempts at collision detection. Great video. Subscribed.

    • @rustwithoutrust
      @rustwithoutrust 2 месяца назад

      thanks! yeah, most of those ways aren't that obvious initially

    • @alleycatsphinx
      @alleycatsphinx 2 месяца назад

      octrees or octonion trees?

    • @wiktorwektor123
      @wiktorwektor123 2 месяца назад

      Octtree is exactly the same but in 3d. Instead of 4 leaves in node you have 8.

  • @NinetyUnderScore
    @NinetyUnderScore 2 месяца назад

    quadtrees make me happy

  • @Tiparium_NMF
    @Tiparium_NMF 2 месяца назад

    How well do quadtrees adapt to three dimensions? I have a project that handles hundreds of thousands of particle interactions in 3D space, the approach I used was fixed grid where particles only talk to other particles in their own or adjacent grid slots. But because the grid is fixed, it can still have fairly substantial performance slowdowns if the particles are forced to congregate.

  • @gsestream
    @gsestream 2 месяца назад

    sometimes you only need to sort bounding volume axis limits to get the collisions in O(n) time, faster than quadtrees.

    • @ClokworkGremlin
      @ClokworkGremlin 2 месяца назад

      The thing about Bound and Sweep is that it's only O(n) *after* the bounds have been sorted. Nearly all known sorting algorithms are O(nlogn), which quad trees are too, so while Bound and Sweep is a lot faster than a brute force approach (where you test every possible collision) would be, it's still slower than most spatial hashing algorithms, including the one featured in this video. I actually just spent some time implementing and testing in my collision test bench, and while it's competitive at <100 points, it falls off rapidly at 1000+.

    • @gsestream
      @gsestream 2 месяца назад

      @@ClokworkGremlin use O(n) sorting algorithm, like radix binary tree sort, you can add and remove items from the tree super fast without a new sort also, I just also tested that sorting algorithm in java against Arrays.sort, holds up until like millions of elements, because of system sort native optimizations.

    • @gsestream
      @gsestream 2 месяца назад

      @@ClokworkGremlin yes you can modify the axis sort tree just like with 2d quad tree and 3d octree.

    • @gsestream
      @gsestream 2 месяца назад

      @@ClokworkGremlin in other words, you can separate the axes for the limit values completely, ie separately check x, y and z axes limit intersections. and use linear time sort. ironically radix binary tree sort is 1D binary tree.

  • @strawberryutopia
    @strawberryutopia 2 месяца назад

    Those last 10 seconds was something I never quite got with quad trees, until I saw this video. So like… because cells overlap, an object can be in multiple cells? That’s subtle but genius!

    • @rustwithoutrust
      @rustwithoutrust 2 месяца назад

      Yes, if the cells overlap by 2 object radiuses, then collisions can be easily handled between several cells.

    • @strawberryutopia
      @strawberryutopia 2 месяца назад

      @@rustwithoutrust 🌌🧠

    • @ClokworkGremlin
      @ClokworkGremlin 2 месяца назад

      When I did my test implementation, I made it so that cells aren't split in half, they're split based on the bounds of the objects within them, so almost all cells overlap, but if two objects might be colliding then they're guaranteed to both be in at least one cell.

    • @Dystisis
      @Dystisis 2 месяца назад

      it's like that with a lot of data structures, like spatial hash maps too.

  • @GuyMichaely
    @GuyMichaely 2 месяца назад

    Pronunciation feedback, if you're interested: the "i" in linear is pronounced the same as in "pin"

  • @DanDeebster
    @DanDeebster 2 месяца назад

    That's some weird looking Rust code.

    • @rustwithoutrust
      @rustwithoutrust 2 месяца назад

      that's C

    • @DanDeebster
      @DanDeebster 2 месяца назад

      @@rustwithoutrust Indeed. C wasn't what I had in mind from Rust Without Rust!

    • @reo101
      @reo101 2 месяца назад

      same, lmao

    • @rustwithoutrust
      @rustwithoutrust 2 месяца назад

      kekw

    • @Argletrough
      @Argletrough 2 месяца назад

      @@DanDeebster Why not? It's right in the name: *without* Rust!

  • @BreadProduct
    @BreadProduct 2 месяца назад

    Hm dynamic area codes. Is this optimal for uniformly sized objects like you have here? Since they are all the same size you could scale the area the objects are located such that the radius of the objects you are testing is so small it might as well just be a location in space. Then you don't have to worry if any object is overlapping more than one area code and you can simplify the collision to two coordinate equality tests.

    • @HansMilling
      @HansMilling 2 месяца назад

      I created map applications in my previous job. Having kilometres/miles of road polygons, buildings, forests, rivers, lakes, cables, lamp posts, side walks etc. a large region could consist of 5 gigabytes of vector data and having the quad trees in files with indexes to the vectors we could zoom anywhere on the map and draw the area in just 20ms. Large vectors would be clipped before drawing to optimise drawing speed. Also large polygons or lines would be stored on upper levels and these span multiple quads.

    • @ClokworkGremlin
      @ClokworkGremlin 2 месяца назад

      Even for uniformly distributed objects, splitting the test area reduces the total number of collision checks which need to be made, so it does help a lot. Where quad trees should be most helpful is when you have irregularly distributed objects, which allows some of the branches to just be ignored entirely.

  • @mgostIH
    @mgostIH 2 месяца назад

    Very nice! I want to use something similar but on GPUs, basically render all these points interacting with each other through gravity (or charge repulsion), I was wondering how fast a Rust implementation would be to render them in real time. How many points did you have in this video and how fast was the simulation? I was wondering what would it be like for ~10k points, and also whether you multithreaded this, I think quadtrees might be a bit hard to parallelize but the spatial partitioning idea seems simpler.

    • @rustwithoutrust
      @rustwithoutrust 2 месяца назад

      kul-sudo/quadtrees on GitHub. Have it done with gravity.

  • @rawallon
    @rawallon 2 месяца назад

    Thats craaazy

  • @cobbcoding
    @cobbcoding 2 месяца назад

    BLAZINGLY FAST 🔥🔥🔥

  • @tiagotiagot
    @tiagotiagot 2 месяца назад

    I dunno if the effort pays out; but if the overhead from converting to and from hexagonal coordinates doesn't cancel out the benefits; you would have just run the check one time on 12 cells, instead doing one check on 8 and then a second check on up to almost all the additional surrounding 16 cells around that; or if the second check is not that costly, then you would be checking 6 cells, and then up to just another 6 in the worse case scenario as opposed to up to almost 16 with the square grid. The data would still be stored in a square-based grid, but the coordinates would be offset horizontally every other layer and the vertical distances squished accordingly. RedBlobGames got a great article written about various techniques on hexagonal grids, might be worth a read; I was trying to find out if there was specific technical name for this and seems there's a lot of variations on how to handle things; Wikipedia mentioned HECS might be more efficient method for hexagonal coords; I haven't read about this area in while, so I dunno what else is out there and what are the pros and cons of the various alternatives

  • @NightOwlAmbient
    @NightOwlAmbient 3 месяца назад

    I am writing a custom replication driver for the Unreal engine, and this might be a useful way to cull the list of actors which need to be replicated to a player. Look up "Replication Graph" if you are interested in how Epic did it. They use the same grid system to create the set of actors which are in visual range of the player, but then they pretty much brute force the selection process. For my game, I need the minions to be able to find a target quickly since there will be hundreds of minions per player near the end of the game and the search has to happen on every frame. Minions which are attacking the player need to be prioritized over everything else so the player can respond. I am writing a custom replication driver because the current implementations don't combine targeting and proximity. Thanks for giving me something to think about.

  • @ThankYouESM
    @ThankYouESM 3 месяца назад

    I'm trying to somewhat do this in pygame, but... I want it to create smooth shapes of the matching colors... even shapes like spirals. Technically... every matching color within a pixel distance of 10 must gravitate into each other until they create a smooth edge. if too small of a number of the same color... then make that small cluster move to the next nearest of the same color.

  • @RyanLynch1
    @RyanLynch1 3 месяца назад

    please make a new version of this video where you go slower and more in depth and from first principles or something like that. thanks

  • @BenMcNelly
    @BenMcNelly 3 месяца назад

    Very cool

  • @radicant7283
    @radicant7283 3 месяца назад

    What's spatial hashing though?

    • @rustwithoutrust
      @rustwithoutrust 3 месяца назад

      pos.x / cell width, pos.y / cell height is the hash function here for getting the cell by the position. But many seem to criticize me for this terminology.

    • @lunchbox1553
      @lunchbox1553 3 месяца назад

      ​@@rustwithoutrust You're only listing inputs without explaining the concept you titled this video.