Skip to content

Commit

Permalink
add ctype-based filt shift modes (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
krawthekrow authored and jacob1 committed Nov 7, 2016
1 parent 57f5d0f commit 63b2227
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/gui/game/GameView.cpp
Expand Up @@ -2290,8 +2290,8 @@ void GameView::OnDraw()
else if (type == PT_FILT)
{
sampleInfo << c->ElementResolve(type, ctype);
const char* filtModes[] = {"set colour", "AND", "OR", "subtract colour", "red shift", "blue shift", "no effect", "XOR", "NOT", "old QRTZ scattering"};
if (sample.particle.tmp>=0 && sample.particle.tmp<=9)
const char* filtModes[] = {"set colour", "AND", "OR", "subtract colour", "red shift", "blue shift", "no effect", "XOR", "NOT", "old QRTZ scattering", "variable red shift", "variable blue shift"};
if (sample.particle.tmp>=0 && sample.particle.tmp<=11)
sampleInfo << " (" << filtModes[sample.particle.tmp] << ")";
else
sampleInfo << " (unknown mode)";
Expand Down
30 changes: 20 additions & 10 deletions src/simulation/elements/FILT.cpp
Expand Up @@ -89,17 +89,17 @@ int Element_FILT::interactWavelengths(Particle* cpart, int origWl)
case 3:
return origWl & (~filtWl); //Subtract colour of filt from colour of photon
case 4:
{
int shift = int((cpart->temp-273.0f)*0.025f);
if (shift<=0) shift = 1;
return (origWl << shift) & mask; // red shift
}
{
int shift = int((cpart->temp-273.0f)*0.025f);
if (shift<=0) shift = 1;
return (origWl << shift) & mask; // red shift
}
case 5:
{
int shift = int((cpart->temp-273.0f)*0.025f);
if (shift<=0) shift = 1;
return (origWl >> shift) & mask; // blue shift
}
{
int shift = int((cpart->temp-273.0f)*0.025f);
if (shift<=0) shift = 1;
return (origWl >> shift) & mask; // blue shift
}
case 6:
return origWl; // No change
case 7:
Expand All @@ -113,6 +113,16 @@ int Element_FILT::interactWavelengths(Particle* cpart, int origWl)
int t3 = ((origWl & 0xFF0000)>>16)+(rand()%5)-2;
return (origWl & 0xFF000000) | (t3<<16) | (t2<<8) | t1;
}
case 10:
{
long long int lsb = filtWl & (-filtWl);
return (origWl * lsb) & 0x3FFFFFFF; //red shift
}
case 11:
{
long long int lsb = filtWl & (-filtWl);
return (origWl / lsb) & 0x3FFFFFFF; // blue shift
}
default:
return filtWl;
}
Expand Down

0 comments on commit 63b2227

Please sign in to comment.