mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2026-05-16 16:06:13 +08:00
Ped clothes not exploding
This commit is contained in:
@@ -80,6 +80,8 @@ namespace CodeWalker.Rendering
|
||||
|
||||
public bool EnableRootMotion = false; //used to toggle whether or not to include root motion when playing animations
|
||||
|
||||
public ClothInstance Cloth;
|
||||
|
||||
|
||||
public override void Init(DrawableBase drawable)
|
||||
{
|
||||
|
||||
+10
-2
@@ -2509,7 +2509,7 @@ namespace CodeWalker.Rendering
|
||||
return res;
|
||||
}
|
||||
|
||||
public bool RenderDrawable(DrawableBase drawable, Archetype arche, YmapEntityDef entity, uint txdHash = 0, TextureDictionary txdExtra = null, Texture diffOverride = null, ClipMapEntry animClip = null)
|
||||
public bool RenderDrawable(DrawableBase drawable, Archetype arche, YmapEntityDef entity, uint txdHash = 0, TextureDictionary txdExtra = null, Texture diffOverride = null, ClipMapEntry animClip = null, ClothInstance cloth = null)
|
||||
{
|
||||
//enqueue a single drawable for rendering.
|
||||
|
||||
@@ -2534,6 +2534,9 @@ namespace CodeWalker.Rendering
|
||||
rndbl.ResetBoneTransforms();
|
||||
}
|
||||
|
||||
rndbl.Cloth = cloth;
|
||||
|
||||
|
||||
return RenderRenderable(rndbl, arche, entity);
|
||||
}
|
||||
|
||||
@@ -2596,6 +2599,10 @@ namespace CodeWalker.Rendering
|
||||
{
|
||||
rndbl.UpdateAnims(currentRealTime);
|
||||
}
|
||||
if (rndbl.Cloth != null)
|
||||
{
|
||||
rndbl.Cloth.Update(currentRealTime);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2795,6 +2802,7 @@ namespace CodeWalker.Rendering
|
||||
//var compData = ped.Ymt?.VariationInfo?.GetComponentData(i);
|
||||
var drawable = ped.Drawables[i];
|
||||
var texture = ped.Textures[i];
|
||||
var cloth = ped.Clothes[i];
|
||||
|
||||
//if (compData == null) return;
|
||||
if (drawable == null) return;
|
||||
@@ -2837,7 +2845,7 @@ namespace CodeWalker.Rendering
|
||||
|
||||
if (drawFlag)
|
||||
{
|
||||
RenderDrawable(drawable, null, ped.RenderEntity, 0, td, texture, ac);
|
||||
RenderDrawable(drawable, null, ped.RenderEntity, 0, td, texture, ac, cloth);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -154,6 +154,7 @@ namespace CodeWalker.Rendering
|
||||
GpuVarsBuffer<BasicShaderInstGlobals> InstGlobalVars;
|
||||
GpuVarsBuffer<BasicShaderInstLocals> InstLocalVars;
|
||||
GpuABuffer<Matrix3_s> BoneMatrices;
|
||||
GpuABuffer<Vector4> ClothVertices;
|
||||
SamplerState texsampler;
|
||||
SamplerState texsampleranis;
|
||||
SamplerState texsamplertnt;
|
||||
@@ -244,6 +245,7 @@ namespace CodeWalker.Rendering
|
||||
InstGlobalVars = new GpuVarsBuffer<BasicShaderInstGlobals>(device);
|
||||
InstLocalVars = new GpuVarsBuffer<BasicShaderInstLocals>(device);
|
||||
BoneMatrices = new GpuABuffer<Matrix3_s>(device, 255);
|
||||
ClothVertices = new GpuABuffer<Vector4>(device, 254);
|
||||
|
||||
InitInstGlobalVars();
|
||||
|
||||
@@ -584,6 +586,10 @@ namespace CodeWalker.Rendering
|
||||
SetBoneMatrices(context, defaultBoneMatrices);
|
||||
defaultBoneMatricesBound = true;
|
||||
}
|
||||
if (model.Owner.Cloth?.Vertices != null)
|
||||
{
|
||||
SetClothVertices(context, model.Owner.Cloth.Vertices);
|
||||
}
|
||||
|
||||
if (!model.UseTransform) return;
|
||||
VSModelVars.Vars.Transform = Matrix.Transpose(model.Transform);
|
||||
@@ -829,6 +835,12 @@ namespace CodeWalker.Rendering
|
||||
BoneMatrices.SetVSCBuffer(context, 7);
|
||||
}
|
||||
|
||||
public void SetClothVertices(DeviceContext context, Vector4[] vertices)
|
||||
{
|
||||
ClothVertices.Update(context, vertices);
|
||||
ClothVertices.SetVSCBuffer(context, 8);
|
||||
}
|
||||
|
||||
|
||||
public void SetInstanceVars(DeviceContext context, RenderableInstanceBatch batch)
|
||||
{
|
||||
@@ -1020,6 +1032,7 @@ namespace CodeWalker.Rendering
|
||||
InstGlobalVars.Dispose();
|
||||
InstLocalVars.Dispose();
|
||||
BoneMatrices.Dispose();
|
||||
ClothVertices.Dispose();
|
||||
|
||||
basicps.Dispose();
|
||||
basicvspnct.Dispose();
|
||||
|
||||
@@ -65,6 +65,7 @@ namespace CodeWalker.Rendering
|
||||
GpuVarsBuffer<ShadowShaderVSModelVars> VSModelVars;
|
||||
GpuVarsBuffer<ShadowShaderGeomVars> GeomVars;
|
||||
GpuABuffer<Matrix3_s> BoneMatrices;
|
||||
GpuABuffer<Vector4> ClothVertices;
|
||||
|
||||
SamplerState texsampler;
|
||||
SamplerState texsamplerc;
|
||||
@@ -94,6 +95,7 @@ namespace CodeWalker.Rendering
|
||||
VSModelVars = new GpuVarsBuffer<ShadowShaderVSModelVars>(device);
|
||||
GeomVars = new GpuVarsBuffer<ShadowShaderGeomVars>(device);
|
||||
BoneMatrices = new GpuABuffer<Matrix3_s>(device, 255);
|
||||
ClothVertices = new GpuABuffer<Vector4>(device, 254);
|
||||
|
||||
|
||||
//supported layouts - requires Position, Normal, Colour, Texcoord
|
||||
@@ -243,6 +245,10 @@ namespace CodeWalker.Rendering
|
||||
SetBoneMatrices(context, defaultBoneMatrices);
|
||||
defaultBoneMatricesBound = true;
|
||||
}
|
||||
if (model.Owner.Cloth?.Vertices != null)
|
||||
{
|
||||
SetClothVertices(context, model.Owner.Cloth.Vertices);
|
||||
}
|
||||
|
||||
if (!model.UseTransform) return;
|
||||
VSModelVars.Vars.Transform = Matrix.Transpose(model.Transform);
|
||||
@@ -378,6 +384,12 @@ namespace CodeWalker.Rendering
|
||||
BoneMatrices.SetVSCBuffer(context, 7);
|
||||
}
|
||||
|
||||
public void SetClothVertices(DeviceContext context, Vector4[] vertices)
|
||||
{
|
||||
ClothVertices.Update(context, vertices);
|
||||
ClothVertices.SetVSCBuffer(context, 8);
|
||||
}
|
||||
|
||||
|
||||
public override void UnbindResources(DeviceContext context)
|
||||
{
|
||||
@@ -415,6 +427,7 @@ namespace CodeWalker.Rendering
|
||||
VSModelVars.Dispose();
|
||||
GeomVars.Dispose();
|
||||
BoneMatrices.Dispose();
|
||||
ClothVertices.Dispose();
|
||||
|
||||
|
||||
shadowps.Dispose();
|
||||
|
||||
Reference in New Issue
Block a user