Example #1
0
func (self *MultiplayerManager) drawAirplanes(phase display.DrawingPhase, isBefore bool, ref interface{}) int {
	defer func() {
		self.dumpDebugInfo = false
	}()
	if len(self.planes) == 0 {
		if self.dumpDebugInfo {
			logging.Debug("No planes this cycle.")
		}
		return 1
	}
	is_shadow := self.wrtDataRef != nil && dataAccess.GetIntData(self.wrtDataRef) != 0
	if self.prtDataRef != nil {
		self.isBlend = dataAccess.GetIntData(self.prtDataRef) == 2
	}
	var blendValue bool
	if is_shadow {
		blendValue = false
	} else {
		blendValue = self.isBlend
	}
	var startTime time.Time
	if self.dumpDebugInfo {
		startTime = time.Now()
	}
	self.planesMutex.RLock()
	self.renderer.Render(blendValue, self.renderAircraftLabels, self.planes, self.rendererRef)
	self.planesMutex.RUnlock()
	if !is_shadow {
		self.isBlend = !self.isBlend
	}
	if self.dumpDebugInfo {
		logging.Debugf("Drawing time: %v", time.Now().Sub(startTime))
		logging.Debug("Dumping one cycle map of planes")
		self.planesMutex.RLock()
		for _, plane := range self.planes {
			logging.Debugf("[%v] - icao=%v, airline=%v, livery:=%v", plane.PlaneId, plane.CslAircraft.Icao, plane.CslAircraft.Airline, plane.CslAircraft.Livery)
			if plane.PositionData == nil {
				logging.Debugf("Drawing plane: %v at <no position data>", plane.CslAircraft.ObjFile)
			} else {
				logging.Debugf("Drawing plane: %v at %v,%v,%v (%vx%vx%v full=%v)", plane.CslAircraft.ObjFile, plane.PositionData.Lat, plane.PositionData.Lon, plane.PositionData.Elevation, plane.PositionData.Pitch, plane.PositionData.Roll, plane.PositionData.Heading, plane.RenderFull)
			}
		}
		self.planesMutex.RUnlock()
		logging.Debug("End of cycle dump.")
	}
	return 1
}
Example #2
0
func (self *AircraftTest) testFlightLoop(elapsedSinceLastCall, elapsedTimeSinceLastFlightLoop float32, counter int, ref interface{}) float32 {
	if self.currentTestPlaneId > 0 {
		self.multiplayerManager.DestroyPlane(self.currentTestPlaneId)
	}
	if self.currentIndex >= len(self.allAircrafts) {
		processing.UnregisterFlightLoopCallback(self.testFlightLoop, nil)
		self.multiplayerManager.GetConfiguration().CalculationMod = self.oldConfigMod
		return 0
	}
	currentAircraft := self.allAircrafts[self.currentIndex]
	logging.Debugf("testing Plane: index=%v/%v icao=%v airline=%v livery=%v", self.currentIndex, len(self.allAircrafts), currentAircraft.Icao, currentAircraft.Airline, currentAircraft.Livery)
	self.currentTestPlaneId = self.multiplayerManager.CreatePlane(currentAircraft.Icao, currentAircraft.Airline, currentAircraft.Livery, self.testDataFunc, currentAircraft)
	self.currentIndex += 1
	return 0.125

}