add ctype-based filt shift modes (#351)

This commit is contained in:
krawthekrow 2016-10-24 12:20:06 +08:00 committed by jacob1
parent 57f5d0f84f
commit 63b2227802
2 changed files with 22 additions and 12 deletions

View File

@ -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)";

View File

@ -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:
@ -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;
}