Movable Solids now simple

  • meep2000
    29th Apr 2011 Member 0 Permalink
    add "void* data" to particle definition
    add the following struct

    struct particle_connection {
    int other;
    particle* pointer;
    float dist;
    float spring; //normally 0.1
    when the particles are created and at other times (like when metal unmelts), do this

    or something like this anyways. variables, functions and C syntax (no C++ or Java) may need to be fixed.

    //this is run whenever the particle needs to have some bonding time with other particles
    //oh it should prolly check when these particles are gonna die, shouldn't it
    //otherwise major glitching... crap I can't think of a way to detect that.
    parts[i].data=new particle_connection[8];
    int numd=0;
    for(int x=rx-1;xfor(int y=ry-1;yif(0particle p=partmap[x][y];
    if(/*can connect to this, maybe check types*/){
    particle_connection& newpc=(particle_connection*)parts[i].data+numd*12
    /*is that necessary or does C multiply pointer offsets by type size?*/
    newpc.other=p.number;
    newpc.pointer=&newpc;
    newpc.spring=0.3; //or some other number depending on the material
    newpc.dist=//distance between myself and the other particle
    }
    }

    //this is run whenever the particle is calculating its physics
    int numpc=0;
    particle_connection pclist[]=parts[i].data;
    particle cp=pclist[numpc];
    while(numpc<8){<br />if(cp.pointer==null){
    numpc=8;
    } else {
    if(YOUR PARTICLE GOT PWNED BY VOID OR SOMETHING){
    int tnumpc=numpc;
    while(tnumpc<7)<br />pclist[tnumpc]=pclist[tnumpc+1];
    pclist[7].other=0;
    pclist[7].pointer=0;
    pclist[7].dist=0.0;
    pclist[7].spring=0.0;
    } else {
    float dx=cp.x-x;
    float dy=cp.y-y;
    float dd=cp.spring*(sqrt(dx*dx+dy*dy)/cp.dist-1.0)
    vx+=dd*dx;
    vy+=dd*dy;
    numpc++;
    cp=pclist[numpc];
    }
    }
    }


    ... yes I am a programmer
    no I do not eat girl scout cookies.
  • vanquish349
    29th Apr 2011 Member 0 Permalink
    have you tried it
  • Uberness
    29th Apr 2011 Member 0 Permalink

    meep2000:


    no I do not eat girl scout cookies.

    LOL!
  • randalserrano
    29th Apr 2011 Member 0 Permalink
    if it works, you will be a legend!
  • me4502
    29th Apr 2011 Member 0 Permalink
    has anyone tried it yet???
  • TheTempest
    29th Apr 2011 Member 0 Permalink
    Someone, PLEASE try this. It could be epic.
  • rrusciguy
    29th Apr 2011 Member 0 Permalink
    @TheTempest (View Post)
    Yes, and if it is put into a mod it will get people to shut up about them.....I hope......
  • TheTempest
    29th Apr 2011 Member 0 Permalink
    Yeah. Plus as n00b as it sounds, I think on the inside we all would be happy if we could have movable solids. I think the repeated requests have made us agitated at the mention of them, but the idea itself is quite nice:)
  • me4502
    29th Apr 2011 Member 0 Permalink
    I would try it but I dotn have access to my computer

    Edit

    Could you explain it a little bit more...

    What is the particle definition is it powder.h

    edit:

    im working on testing it

    please fix up some bits of code

    parts[i].data=new particle_connection[8]; - new gives error

    for(int x=rx-1;xfor(int y=ry-1;yif(0particle p=partmap[x][y]; - gives error about use of int - invalid suffix particle on int
  • Ace
    29th Apr 2011 Member 0 Permalink

    TheTempest:

    n00b as it sounds

    The only n00bz are the people who don't want moving solids. It's only n00b if you ignore the people who tell you it's simply too hard.
Locked by cracker64: Moving solids