Further lighting optimization, fixed (railgun) controller movement, physicsbody collisioncategory changes, command room reactor controls in Vellamo

This commit is contained in:
Regalis11
2015-10-14 22:10:37 +03:00
parent 8df9133e84
commit 2bb5d41836
27 changed files with 135 additions and 126 deletions

View File

@@ -664,7 +664,7 @@ int currentTargetIndex = 1;
edgeBody.UserData = cell;
edgeBody.SleepingAllowed = false;
edgeBody.BodyType = BodyType.Kinematic;
edgeBody.CollisionCategories = Physics.CollisionWall | Physics.CollisionLevel;
edgeBody.CollisionCategories = Physics.CollisionLevel;
cell.body = edgeBody;
bodies.Add(edgeBody);
@@ -674,7 +674,7 @@ int currentTargetIndex = 1;
{
Body shaftBody = BodyFactory.CreateRectangle(GameMain.World, 100.0f, 10.0f, 5.0f);
shaftBody.BodyType = BodyType.Kinematic;
shaftBody.CollisionCategories = Physics.CollisionWall | Physics.CollisionLevel;
shaftBody.CollisionCategories = Physics.CollisionLevel;
shaftBody.SetTransform(ConvertUnits.ToSimUnits((i==0) ? startPosition : endPosition), 0.0f);
shaftBody.SleepingAllowed = false;
bodies.Add(shaftBody);

View File

@@ -12,7 +12,7 @@ namespace Subsurface.Lights
public Color AmbientLight;
RenderTarget2D lightMap;
private static Texture2D alphaClearTexture;
private List<LightSource> lights;
@@ -21,10 +21,10 @@ namespace Subsurface.Lights
public bool LightingEnabled = true;
public RenderTarget2D LightMap
{
get { return lightMap; }
}
//public RenderTarget2D LightMap
//{
// get { return lightMap; }
//}
public LightManager(GraphicsDevice graphics)
{
@@ -34,7 +34,8 @@ namespace Subsurface.Lights
var pp = graphics.PresentationParameters;
lightMap = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight, false,
lightMap = new RenderTarget2D(graphics,
GameMain.GraphicsWidth, GameMain.GraphicsHeight, false,
pp.BackBufferFormat, pp.DepthStencilFormat, pp.MultiSampleCount,
RenderTargetUsage.DiscardContents);
@@ -81,8 +82,10 @@ namespace Subsurface.Lights
}
}
public void DrawLightmap(GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam)
public void UpdateLightMap(GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam)
{
if (!LightingEnabled) return;
Matrix shadowTransform = cam.ShaderTransform
* Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
@@ -96,7 +99,7 @@ namespace Subsurface.Lights
foreach (LightSource light in lights)
{
if (light.Color.A < 0.01f || light.Range < 0.01f || light.hullsInRange.Count == 0) continue;
if (light.hullsInRange.Count == 0 || light.Color.A < 0.01f || light.Range < 1.0f) continue;
if (!MathUtils.CircleIntersectsRectangle(light.Position, light.Range, viewRect)) continue;
//clear alpha to 1
@@ -126,7 +129,7 @@ namespace Subsurface.Lights
//foreach (LightSource light in lights)
//{
// if (light.Color.A < 0.01f || light.Range < 0.01f || light.hullsInRange.Count > 0) continue;
// if (light.hullsInRange.Count > 0 || light.Color.A < 0.01f || light.Range < 1.0f) continue;
// if (!MathUtils.CircleIntersectsRectangle(light.Position, light.Range, viewRect)) continue;
// light.Draw(spriteBatch);
@@ -145,6 +148,16 @@ namespace Subsurface.Lights
spriteBatch.Draw(alphaClearTexture, new Rectangle(0, 0,graphics.Viewport.Width, graphics.Viewport.Height), Color.White);
spriteBatch.End();
}
public void DrawLightMap(SpriteBatch spriteBatch, Camera cam)
{
if (!LightingEnabled) return;
//multiply scene with lightmap
spriteBatch.Begin(SpriteSortMode.Immediate, CustomBlendStates.Multiplicative);
spriteBatch.Draw(lightMap, Vector2.Zero, Color.White);
spriteBatch.End();
}
}

View File

@@ -72,7 +72,7 @@ namespace Subsurface.Lights
public void UpdateHullsInRange()
{
hullsInRange.Clear();
if (range < 1.0f) return;
if (range < 1.0f || color.A < 0.01f) return;
foreach (ConvexHull ch in ConvexHull.list)
{