//========================================================================== // // // //========================================================================== void ADynamicLight::Serialize(FArchive &arc) { Super::Serialize (arc); arc << lightflags << lighttype; arc << m_tickCount << m_currentIntensity; arc << m_intensity[0] << m_intensity[1]; if (lighttype == PulseLight) arc << m_lastUpdate << m_cycler; if (arc.IsLoading()) LinkLight(); }
//========================================================================== // // // //========================================================================== void ADynamicLight::Serialize(FArchive &arc) { Super::Serialize (arc); arc << lightflags << lighttype; arc << m_tickCount << m_currentRadius; arc << m_Radius[0] << m_Radius[1]; if (lighttype == PulseLight) arc << m_lastUpdate << m_cycler; if (arc.IsLoading()) { // The default constructor which is used for creating objects before deserialization will not set this variable. // It needs to be true for all placed lights. visibletoplayer = true; LinkLight(); } }
//========================================================================== // // // //========================================================================== void ADynamicLight::UpdateLocation() { fixed_t oldx=X(); fixed_t oldy=Y(); fixed_t oldradius=radius; float intensity; if (IsActive()) { if (target) { angle_t angle = target->angle>>ANGLETOFINESHIFT; fixedvec3 pos = target->Vec3Offset( FixedMul(m_offX, finecosine[angle]) + FixedMul(m_offZ, finesine[angle]), FixedMul(m_offX, finesine[angle]) - FixedMul(m_offZ, finecosine[angle]), m_offY + target->GetBobOffset()); SetXYZ(pos); // attached lights do not need to go into the regular blockmap PrevX = pos.x; PrevY = pos.y; PrevZ = pos.z; subsector = R_PointInSubsector(pos.x, pos.y); Sector = subsector->sector; } // The radius being used here is always the maximum possible with the // current settings. This avoids constant relinking of flickering lights if (lighttype == FlickerLight || lighttype == RandomFlickerLight) { intensity = float(m_intensity[1]); } else { intensity = m_currentIntensity; } radius = FLOAT2FIXED(intensity * 2.0f * gl_lights_size); if (X()!=oldx || Y()!=oldy || radius!=oldradius) { //Update the light lists LinkLight(); } } }
//========================================================================== // // // //========================================================================== void ADynamicLight::UpdateLocation() { double oldx= X(); double oldy= Y(); double oldradius= radius; float intensity; if (IsActive()) { if (target) { DAngle angle = target->Angles.Yaw; double s = angle.Sin(); double c = angle.Cos(); DVector3 pos = target->Vec3Offset(m_off.X * c + m_off.Y * s, m_off.X * s - m_off.Y * c, m_off.Z + target->GetBobOffset()); SetXYZ(pos); // attached lights do not need to go into the regular blockmap Prev = target->Pos(); subsector = R_PointInSubsector(Prev); Sector = subsector->sector; } // The radius being used here is always the maximum possible with the // current settings. This avoids constant relinking of flickering lights if (lighttype == FlickerLight || lighttype == RandomFlickerLight || lighttype == PulseLight) { intensity = float(MAX(m_Radius[0], m_Radius[1])); } else { intensity = m_currentRadius; } radius = intensity * 2.0f * gl_lights_size; if (X() != oldx || Y() != oldy || radius != oldradius) { //Update the light lists LinkLight(); } } }
//========================================================================== // // // //========================================================================== void ADynamicLight::UpdateLocation() { fixed_t oldx=x; fixed_t oldy=y; fixed_t oldradius=radius; float intensity; if (IsActive()) { if (target) { angle_t angle = target->angle>>ANGLETOFINESHIFT; PrevX = x = target->x + FixedMul(m_offX, finecosine[angle]) + FixedMul(m_offZ, finesine[angle]); PrevY = y = target->y + FixedMul(m_offX, finesine[angle]) - FixedMul(m_offZ, finecosine[angle]); PrevZ = z = target->z + m_offY + target->GetBobOffset(); subsector = R_PointInSubsector(x, y); Sector = subsector->sector; } // The radius being used here is always the maximum possible with the // current settings. This avoids constant relinking of flickering lights if (lighttype == FlickerLight || lighttype == RandomFlickerLight) { intensity = float(m_intensity[1]); } else { intensity = m_currentIntensity; } radius = FLOAT2FIXED(intensity * 2.0f * gl_lights_size); if (x!=oldx || y!=oldy || radius!=oldradius) { //Update the light lists LinkLight(); } } }
void ADynamicLight::SetOrigin(double x, double y, double z, bool moving) { Super::SetOrigin(x, y, z, moving); LinkLight(); }