LCOV - code coverage report
Current view: top level - Core/Entities - OOEntityWithDrawable.m (source / functions) Hit Total Coverage
Test: coverxygen.info Lines: 0 5 0.0 %
Date: 2025-05-28 07:50:54 Functions: 0 0 -

          Line data    Source code
       1           0 : /*
       2             : 
       3             : OOEntityWithDrawable.m
       4             : 
       5             : Oolite
       6             : Copyright (C) 2004-2013 Giles C Williams and contributors
       7             : 
       8             : This program is free software; you can redistribute it and/or
       9             : modify it under the terms of the GNU General Public License
      10             : as published by the Free Software Foundation; either version 2
      11             : of the License, or (at your option) any later version.
      12             : 
      13             : This program is distributed in the hope that it will be useful,
      14             : but WITHOUT ANY WARRANTY; without even the implied warranty of
      15             : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16             : GNU General Public License for more details.
      17             : 
      18             : You should have received a copy of the GNU General Public License
      19             : along with this program; if not, write to the Free Software
      20             : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
      21             : MA 02110-1301, USA.
      22             : 
      23             : */
      24             : 
      25             : 
      26             : #import "OOEntityWithDrawable.h"
      27             : #import "OODrawable.h"
      28             : #import "Universe.h"
      29             : #import "ShipEntity.h"
      30             : #import "OOVisualEffectEntity.h"
      31             : 
      32             : @implementation OOEntityWithDrawable
      33             : 
      34           0 : - (void)dealloc
      35             : {
      36             :         [drawable release];
      37             :         drawable = nil;
      38             :         
      39             :         [super dealloc];
      40             : }
      41             : 
      42             : 
      43             : - (OODrawable *)drawable
      44             : {
      45             :         return drawable;
      46             : }
      47             : 
      48             : 
      49             : - (void)setDrawable:(OODrawable *)inDrawable
      50             : {
      51             :         if (inDrawable != drawable)
      52             :         {
      53             :                 [drawable autorelease];
      54             :                 drawable = [inDrawable retain];
      55             :                 [drawable setBindingTarget:self];
      56             :                 
      57             :                 collision_radius = [drawable collisionRadius];
      58             :                 no_draw_distance = [drawable maxDrawDistance];
      59             :                 boundingBox = [drawable boundingBox];
      60             :         }
      61             : }
      62             : 
      63             : 
      64           0 : - (double)findCollisionRadius
      65             : {
      66             :         return [drawable collisionRadius];
      67             : }
      68             : 
      69             : 
      70           0 : - (void) drawImmediate:(bool)immediate translucent:(bool)translucent
      71             : {
      72             :         if (no_draw_distance < cam_zero_distance)
      73             :         {
      74             :                 // Don't draw.
      75             :                 return;
      76             :         }
      77             :         
      78             :         if (no_draw_distance != INFINITY && ![self isImmuneToBreakPatternHide])
      79             :         { 
      80             :                 // (always draw sky, always draw break patterns)
      81             :                 if (![self isSubEntity]) 
      82             :                 {
      83             :                         GLfloat clipradius = collision_radius;
      84             :                         if ([self isShip])
      85             :                         {
      86             :                                 ShipEntity* shipself = (ShipEntity*)self;
      87             :                                 clipradius = [shipself frustumRadius];
      88             :                         }
      89             :                         else if ([self isVisualEffect])
      90             :                         {
      91             :                                 OOVisualEffectEntity* veself = (OOVisualEffectEntity*)self;
      92             :                                 clipradius = [veself frustumRadius];
      93             :                         }
      94             :                         // don't bother with frustum culling within/near collision radius, as
      95             :                         // potential for problems with floating point inaccuracy causing
      96             :                         // unwanted disappearance maybe fix
      97             :                         // http://aegidian.org/bb/viewtopic.php?f=3&t=13619 - CIM
      98             :                         if (cam_zero_distance > (clipradius+1000)*(clipradius+1000))
      99             :                         {
     100             :                                 if (![UNIVERSE viewFrustumIntersectsSphereAt:cameraRelativePosition withRadius:clipradius])
     101             :                                 {
     102             :                                         return;
     103             :                                 }
     104             :                         }
     105             :                 } 
     106             :                 else // is subentity
     107             :                 {
     108             :                         // don't bother with frustum culling within 1km, as above - CIM
     109             :                         if (cam_zero_distance > (collision_radius+1000)*(collision_radius+1000))
     110             :                         {
     111             :                                 // check correct sub-entity position
     112             :                                 if (![UNIVERSE viewFrustumIntersectsSphereAt:cameraRelativePosition withRadius:[self collisionRadius]])
     113             :                                 {
     114             :                                         return;
     115             :                                 }
     116             :                         }
     117             :                 }
     118             :         }       
     119             : 
     120             :         if ([UNIVERSE wireframeGraphics])  OOGLWireframeModeOn();
     121             :                 
     122             :         if (translucent)  [drawable renderTranslucentParts];
     123             :         else  [drawable renderOpaqueParts];
     124             :         
     125             :         if ([UNIVERSE wireframeGraphics])  OOGLWireframeModeOff();
     126             : }
     127             : 
     128             : 
     129             : #ifndef NDEBUG
     130           0 : - (NSSet *) allTextures
     131             : {
     132             :         return [[self drawable] allTextures];
     133             : }
     134             : #endif
     135             : 
     136             : @end

Generated by: LCOV version 1.14