- Fixed light source placement

- Removed unnecessary texturemanager reference
This commit is contained in:
Andreas Schneider 2009-12-21 00:55:19 +01:00
parent 5049955303
commit a7c74c114e
2 changed files with 4 additions and 11 deletions

View File

@ -83,8 +83,7 @@ type
{ TLightManager } { TLightManager }
TLightManager = class TLightManager = class
constructor Create(ACalculateOffset: TCalculateOffset; constructor Create(ACalculateOffset: TCalculateOffset);
ALandTextureManager: TLandTextureManager);
destructor Destroy; override; destructor Destroy; override;
protected protected
FLightSources: TLightSources; FLightSources: TLightSources;
@ -94,7 +93,6 @@ type
FValid: Boolean; FValid: Boolean;
FCalculateOffset: TCalculateOffset; FCalculateOffset: TCalculateOffset;
FLightCache: TLightCache; FLightCache: TLightCache;
FLandTextureManager: TLandTextureManager;
function GetLight(AID: Integer): TLightMaterial; function GetLight(AID: Integer): TLightMaterial;
procedure UpdateOverlay(AScreenRect: TRect); procedure UpdateOverlay(AScreenRect: TRect);
public public
@ -110,14 +108,12 @@ uses
{ TLightManager } { TLightManager }
constructor TLightManager.Create(ACalculateOffset: TCalculateOffset; constructor TLightManager.Create(ACalculateOffset: TCalculateOffset);
ALandTextureManager: TLandTextureManager);
begin begin
FCalculateOffset := ACalculateOffset; FCalculateOffset := ACalculateOffset;
FLightSources := TLightSources.Create(True); FLightSources := TLightSources.Create(True);
FLightLevel := 15; //TODO : 0 ... FLightLevel := 15; //TODO : 0 ...
FLightCache := TLightCache.Create(32); FLightCache := TLightCache.Create(32);
FLandTextureManager := ALandTextureManager;
end; end;
destructor TLightManager.Destroy; destructor TLightManager.Destroy;
@ -262,17 +258,14 @@ end;
constructor TLightSource.Create(AManager: TLightManager; AWorldItem: TWorldItem); constructor TLightSource.Create(AManager: TLightManager; AWorldItem: TWorldItem);
var var
lightID: Byte; lightID: Byte;
itemMaterial: TMaterial;
begin begin
lightID := ResMan.Tiledata.StaticTiles[AWorldItem.TileID].Quality; lightID := ResMan.Tiledata.StaticTiles[AWorldItem.TileID].Quality;
FMaterial := AManager.GetLight(lightID); FMaterial := AManager.GetLight(lightID);
if FMaterial <> nil then if FMaterial <> nil then
begin begin
itemMaterial := AManager.FLandTextureManager.GetStaticMaterial(
TStaticItem(AWorldItem));
AManager.FCalculateOffset(AWorldItem.X, AWorldItem.Y, FX, FY); AManager.FCalculateOffset(AWorldItem.X, AWorldItem.Y, FX, FY);
FZ := AWorldItem.Z * 4; FZ := AWorldItem.Z * 4;
FY := FY + 44 - FZ - itemMaterial.RealHeight div 2; FY := FY + 22 - FZ;
FMaterial.AddRef; FMaterial.AddRef;
end; end;
end; end;

View File

@ -892,7 +892,7 @@ begin
edX.MaxValue := FLandscape.CellWidth; edX.MaxValue := FLandscape.CellWidth;
edY.MaxValue := FLandscape.CellHeight; edY.MaxValue := FLandscape.CellHeight;
FOverlayUI := TOverlayUI.Create; FOverlayUI := TOverlayUI.Create;
FLightManager := TLightManager.Create(@GetDrawOffset, FTextureManager); FLightManager := TLightManager.Create(@GetDrawOffset);
ProcessAccessLevel; ProcessAccessLevel;