rfc bread and butter dod data structure

monkyyy crazymonkyyy at gmail.com
Tue Jul 15 21:41:33 UTC 2025


Im looking into dod datastructures again

As I said elsewhere I dont believe aosoa is reasonably possible 
without compiler support; however while such packing is likely 
rather important in some cases, its not the entirity of dod 
thought.

consider:

1. batched deletions
2. tagged structs instead of classes
3. bool packing flags
4. radix sorting from user functions(such as sorting objects by 
grid for faster collision checks)
5. indexes over 64 bit pointers

I believe I can make this api work:

```d
import mkydata;
struct shape_(P){
   float width,height;
   float x,y;
   float xv,yv;
   P following;//where P is a magic "pointer", index
}
//struct dodarray(alias T,int i,string[] flags=[],int 
line=__LINE__,string file=__FILE__)
dodarray!(shape_,1000,["isstatic","isdead","iscircle","isrectangle"]) shapes;
alias shape=shapes.value;
alias shapeenum=shapes.enum;
void draw(shape s){
   if(s.isalive){
     if(s.iscircle){
       DrawCircle(...);
     }
     ...
     if(s.follow != null){
       DrawLine(...,s.follow.x,s.follow.y,...);
}
void boundscheck(){
   foreach(s;shapes){
     if(s.x<0||s.x>1080){
     if(s.y<0||s.y>1080){
       s.isdead=true;
}}}
void moveshapes(){
   foreach(s;shapes.filter(isnt:shapeenum.isstatic){
     s.x+=s.xv;
     s.y+=s.yv;
}}
void deletedeadshapes(){
   shapes.deleteby(has:shapeenum.isdead);
}
```

I think the dod book sucks, and I think the rust "database driven 
videogame" guy is a uncle bob conartist. But are there other 
ideas I should keep in mind?

Has there been any good dod talks in the last few years?




More information about the Digitalmars-d mailing list