mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2025-01-26 15:32:54 +08:00
Fixed grass painting and selection bugs/glitchiness
This commit is contained in:
parent
05d3e37394
commit
1e2e927cf6
@ -936,6 +936,10 @@ namespace CodeWalker.Rendering
|
|||||||
public rage__fwGrassInstanceListDef__InstanceData[] GrassInstanceData { get; set; }
|
public rage__fwGrassInstanceListDef__InstanceData[] GrassInstanceData { get; set; }
|
||||||
public GpuSBuffer<rage__fwGrassInstanceListDef__InstanceData> GrassInstanceBuffer { get; set; }
|
public GpuSBuffer<rage__fwGrassInstanceListDef__InstanceData> GrassInstanceBuffer { get; set; }
|
||||||
public int InstanceCount { get; set; }
|
public int InstanceCount { get; set; }
|
||||||
|
public Vector3 AABBMin { get; set; }
|
||||||
|
public Vector3 AABBMax { get; set; }
|
||||||
|
public Vector3 Position { get; set; }
|
||||||
|
public Vector3 CamRel { get; set; }
|
||||||
|
|
||||||
public override void Init(YmapGrassInstanceBatch batch)
|
public override void Init(YmapGrassInstanceBatch batch)
|
||||||
{
|
{
|
||||||
@ -955,6 +959,12 @@ namespace CodeWalker.Rendering
|
|||||||
|
|
||||||
public override void Load(Device device)
|
public override void Load(Device device)
|
||||||
{
|
{
|
||||||
|
if (Key != null)
|
||||||
|
{
|
||||||
|
AABBMin = Key.AABBMin;
|
||||||
|
AABBMax = Key.AABBMax;
|
||||||
|
Position = Key.Position;
|
||||||
|
}
|
||||||
if ((GrassInstanceData != null) && (GrassInstanceData.Length > 0))
|
if ((GrassInstanceData != null) && (GrassInstanceData.Length > 0))
|
||||||
{
|
{
|
||||||
GrassInstanceBuffer = new GpuSBuffer<rage__fwGrassInstanceListDef__InstanceData>(device, GrassInstanceData);
|
GrassInstanceBuffer = new GpuSBuffer<rage__fwGrassInstanceListDef__InstanceData>(device, GrassInstanceData);
|
||||||
|
@ -2081,6 +2081,8 @@ namespace CodeWalker.Rendering
|
|||||||
if (!(rndbl.IsLoaded && (rndbl.AllTexturesLoaded || !waitforchildrentoload))) continue; //not loaded yet
|
if (!(rndbl.IsLoaded && (rndbl.AllTexturesLoaded || !waitforchildrentoload))) continue; //not loaded yet
|
||||||
if ((instb == null) || !instb.IsLoaded) continue;
|
if ((instb == null) || !instb.IsLoaded) continue;
|
||||||
|
|
||||||
|
instb.CamRel = instb.Position - camera.Position;//to gracefully handle batch size changes
|
||||||
|
|
||||||
RenderableInstanceBatchInst binst = new RenderableInstanceBatchInst();
|
RenderableInstanceBatchInst binst = new RenderableInstanceBatchInst();
|
||||||
binst.Batch = instb;
|
binst.Batch = instb;
|
||||||
binst.Renderable = rndbl;
|
binst.Renderable = rndbl;
|
||||||
|
@ -699,7 +699,7 @@ namespace CodeWalker.Rendering
|
|||||||
if (batch.GrassInstanceBuffer == null)
|
if (batch.GrassInstanceBuffer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
VSEntityVars.Vars.CamRel = new Vector4(gb.CamRel, 0.0f);
|
VSEntityVars.Vars.CamRel = new Vector4(batch.CamRel, 0.0f);
|
||||||
VSEntityVars.Vars.Orientation = Quaternion.Identity;
|
VSEntityVars.Vars.Orientation = Quaternion.Identity;
|
||||||
VSEntityVars.Vars.Scale = Vector3.One;
|
VSEntityVars.Vars.Scale = Vector3.One;
|
||||||
VSEntityVars.Vars.HasSkeleton = 0;
|
VSEntityVars.Vars.HasSkeleton = 0;
|
||||||
@ -711,13 +711,13 @@ namespace CodeWalker.Rendering
|
|||||||
|
|
||||||
InstGlobalVars.SetVSCBuffer(context, 5);
|
InstGlobalVars.SetVSCBuffer(context, 5);
|
||||||
|
|
||||||
InstLocalVars.Vars.vecBatchAabbMin = gb.AABBMin;
|
InstLocalVars.Vars.vecBatchAabbMin = batch.AABBMin;
|
||||||
InstLocalVars.Vars.vecBatchAabbDelta = gb.AABBMax - gb.AABBMin;
|
InstLocalVars.Vars.vecBatchAabbDelta = batch.AABBMax - batch.AABBMin;
|
||||||
InstLocalVars.Vars.vecPlayerPos = new Vector4(gb.Position - gb.CamRel, 1.0f);
|
InstLocalVars.Vars.vecPlayerPos = new Vector4(batch.Position - batch.CamRel, 1.0f);
|
||||||
InstLocalVars.Vars._vecCollParams = new Vector2(2.0f, -3.0f);//range, offset
|
InstLocalVars.Vars._vecCollParams = new Vector2(2.0f, -3.0f);//range, offset
|
||||||
InstLocalVars.Vars.fadeAlphaDistUmTimer = new Vector4(0.0f);
|
InstLocalVars.Vars.fadeAlphaDistUmTimer = new Vector4(0.0f);
|
||||||
InstLocalVars.Vars.uMovementParams = new Vector4(0.0f);
|
InstLocalVars.Vars.uMovementParams = new Vector4(0.0f);
|
||||||
InstLocalVars.Vars._fakedGrassNormal = new Vector4(Vector3.Normalize(-gb.CamRel), 0.0f);
|
InstLocalVars.Vars._fakedGrassNormal = new Vector4(Vector3.Normalize(-batch.CamRel), 0.0f);
|
||||||
InstLocalVars.Vars.gScaleRange = gb.Batch.ScaleRange;
|
InstLocalVars.Vars.gScaleRange = gb.Batch.ScaleRange;
|
||||||
InstLocalVars.Vars.gWindBendingGlobals = new Vector4(WindVector.X, WindVector.Y, 1.0f, 1.0f);
|
InstLocalVars.Vars.gWindBendingGlobals = new Vector4(WindVector.X, WindVector.Y, 1.0f, 1.0f);
|
||||||
InstLocalVars.Vars.gWindBendScaleVar = new Vector2(WindVector.Z, WindVector.W);
|
InstLocalVars.Vars.gWindBendScaleVar = new Vector2(WindVector.Z, WindVector.W);
|
||||||
|
@ -1431,12 +1431,18 @@ namespace CodeWalker
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((selectionItem.GrassBatch != null) || (selectionItem.ArchetypeExtension != null) || (selectionItem.EntityExtension != null) || (selectionItem.CollisionBounds != null))
|
if ((selectionItem.ArchetypeExtension != null) || (selectionItem.EntityExtension != null) || (selectionItem.CollisionBounds != null))
|
||||||
{
|
{
|
||||||
bbmin = selectionItem.AABB.Minimum;
|
bbmin = selectionItem.AABB.Minimum;
|
||||||
bbmax = selectionItem.AABB.Maximum;
|
bbmax = selectionItem.AABB.Maximum;
|
||||||
scale = Vector3.One;
|
scale = Vector3.One;
|
||||||
}
|
}
|
||||||
|
if (selectionItem.GrassBatch != null)
|
||||||
|
{
|
||||||
|
bbmin = selectionItem.GrassBatch.AABBMin;
|
||||||
|
bbmax = selectionItem.GrassBatch.AABBMax;
|
||||||
|
scale = Vector3.One;
|
||||||
|
}
|
||||||
if (selectionItem.NavPoly != null)
|
if (selectionItem.NavPoly != null)
|
||||||
{
|
{
|
||||||
Renderer.RenderSelectionNavPoly(selectionItem.NavPoly);
|
Renderer.RenderSelectionNavPoly(selectionItem.NavPoly);
|
||||||
@ -3368,7 +3374,6 @@ namespace CodeWalker
|
|||||||
SelectItem(ms);
|
SelectItem(ms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SelectGrassBatch(YmapGrassInstanceBatch batch)
|
public void SelectGrassBatch(YmapGrassInstanceBatch batch)
|
||||||
{
|
{
|
||||||
if (batch == null)
|
if (batch == null)
|
||||||
|
Loading…
Reference in New Issue
Block a user