Why doesn't it set temp right?

  • Videogamer555
    22nd Jan 2012 Member 0 Permalink
    In the part of the powder.c code that has universal update function (basically what happens to EVERY particle on each frame) I have this code
    {
    int myrandx,myrandy,myrandr;
    if((rand()%10000)<=parts[i].temp){<br/>
    myrandx=rand()%3-1+x;
    myrandy=rand()%3-1+y;
    myrandr=pmap[myrandy][myrandx];
    if ((myrandr&0xff)==PT_NONE){
    create_part(-1,myrandx,myrandy,PT_IRPH);
    parts[myrandr>>8].temp=parts[i].temp*200;
    }
    }
    }

    Ok that < br / > that's in the code box isn't actually in my code. It seems the forum software on this site has a glitch.

    Ok, now on to explain my code and my problem. This code picks a random value. And if the material is hotter then it is more likely to that the "if statement" will return true. The next part of the code checks random spot around the source particle to see if it is empty. If it is it generates a new particle of type IRPH, and immediately assigns it a temperature equal to the source particle. This means that no temperature transfer should occur between the emmitted particle and the source particle. Problem is there IS temperature transfer, and my source particle is dramatically cooled! Default value of the temp of the of the emitted IRPH particle (as set in elementdata.c) is 0kelvin (absolute 0). However this should be overridden by:
    parts[myrandr>>8].temp=parts[i].temp;

    Problem is it is NOT being overridden. And there is a very obvious pattern to it not being overridden. If the above line is changed to
    parts[myrandr>>8].temp=parts[i].temp*200;
    to make the IRPH a VERY HOT upon emission, it becomes obvious when viewing in "heat display" that ONLY the IRPH particles being emitted in the upper left corner are having their temperature set properly!

    Here's a screencap to show what I'm saying.

    image

    Has this type of bug been a common bug among mod creators? If so what is the solution?
  • jacksonmj
    22nd Jan 2012 Developer 0 Permalink
    You set myrandr to pmap[myrandy][myrandx]. If this place is empty, myrandr will be equal to zero.

    pmap is updated by create_part, but myrandr is not updated. myrandr is still equal to zero. Effectively what you are doing is parts[0].temp=parts[i].temp;

    create_part returns the ID of the created particle - use it!
  • Videogamer555
    22nd Jan 2012 Member 0 Permalink

    jacksonmj:

    You set myrandr to pmap[myrandy][myrandx]. If this place is empty, myrandr will be equal to zero.

    pmap is updated by create_part, but myrandr is not updated. myrandr is still equal to zero. Effectively what you are doing is parts[0].temp=parts[i].temp;

    create_part returns the ID of the created particle - use it!


    Thanks for the help.