All checks were successful
Tag and Release Lightless / tag-and-release (push) Successful in 2m9s
# Patchnotes 2.1.0 The changes in this update are more than just "patches". With a new UI, a new feature, and a bunch of bug fixes, improvements and a new member on the dev team, we thought this was more of a minor update. We would like to introduce @tsubasahane of MareCN to the team! We’re happy to work with them to bring Lightless and its features to the CN client as well as having another talented dev bring features and ideas to us. Speaking of which: # Location Sharing (Big shout out to @tsubasahane for bringing this feature) - Are you TIRED of scrambling to find the address of the venue you're in to share with your friends? We are introducing Location Sharing! An optional feature where you can share your location with direct pairs temporarily [30 minutes, 1 hour, 3 hours] minutes or until you turn it off for them. That's up to you! [#125](<#125>) [#49](<Lightless-Sync/LightlessServer#49>) - To share your location with a pair, click the three dots beside the pair and choose a duration to share with them. [#125](<#125>) [#49](<Lightless-Sync/LightlessServer#49>) - To view the location of someone who's shared with you, simply hover over the globe icon! [#125](<#125>) [#49](<Lightless-Sync/LightlessServer#49>) [1] # Model Optimization (Mesh Decimating) - This new option can automatically “simplify” incoming character meshes to help performance by reducing triangle counts. You choose how strong the reduction is (default/recommended is 80%). [#131](<#131>) - Decimation only kicks in when a mesh is above a certain triangle threshold, and only for the items that qualify for it and you selected for. [#131](<#131>) - Hair meshes is always excluded, since simplifying hair meshes is very prone to breaking. - You can find everything under Settings → Performance → Model Optimization. [#131](<#131>) + ** IF YOU HAVE USED DECIMATION IN TESTING, PLEASE CLEAR YOUR CACHE ❗ ** [2] # Animation (PAP) Validation (Safer animations) - Lightless now checks your currently animations to see if they work with your local skeleton/bone mod. If an animation matches, it’s included in what gets sent to other players. If it doesn’t, Lightless will skip it and write a warning to your log showing how many were skipped due to skeleton changes. Its defaulted to Unsafe (off). turn it on if you experience crashes from others users. [#131](<#131>) - Lightless also does the same kind of check for incoming animation files, to make sure they match the body/skeleton they were sent with. [#131](<#131>) - Because these checks can sometimes be a little picky, you can adjust how strict they are in Settings -> General -> Animation & Bones to reduce false positives. [#131](<#131>) # UI Changes (Thanks to @kyuwu for UI Changes) - The top part of the main screen has gotten a makeover. You can adjust the colors of the gradiant in the Color settings of Lightless. [#127](<#127>) [3] - Settings have gotten some changes as well to make this change more universal, and will use the same color settings. [#127](<#127>) - The particle effects of the gradient are toggleable in 'Settings -> UI -> Behavior' [#127](<#127>) - Instead of showing download/upload on bottom of Main UI, it will show VRAM usage and triangles with their optimization options next to it [#138](<#138>) # LightFinder / ShellFinder - UI Changes that follow our new design follow the color codes for the Gradient top as the main screen does. [#127](<#127>) [4] Co-authored-by: defnotken <itsdefnotken@gmail.com> Co-authored-by: azyges <aaaaaa@aaa.aaa> Co-authored-by: cake <admin@cakeandbanana.nl> Co-authored-by: Tsubasa <tsubasa@noreply.git.lightless-sync.org> Co-authored-by: choco <choco@patat.nl> Co-authored-by: celine <aaa@aaa.aaa> Co-authored-by: celine <celine@noreply.git.lightless-sync.org> Co-authored-by: Tsubasahane <wozaiha@gmail.com> Co-authored-by: cake <cake@noreply.git.lightless-sync.org> Reviewed-on: #123
145 lines
5.1 KiB
C#
145 lines
5.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace Nanomesh
|
|
{
|
|
public readonly struct BoneWeight : IEquatable<BoneWeight>, IInterpolable<BoneWeight>
|
|
{
|
|
public readonly int index0;
|
|
public readonly int index1;
|
|
public readonly int index2;
|
|
public readonly int index3;
|
|
public readonly float weight0;
|
|
public readonly float weight1;
|
|
public readonly float weight2;
|
|
public readonly float weight3;
|
|
|
|
public int GetIndex(int i)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0: return index0;
|
|
case 1: return index1;
|
|
case 2: return index2;
|
|
case 3: return index3;
|
|
default: return -1;
|
|
}
|
|
}
|
|
|
|
public float GetWeight(int i)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0: return weight0;
|
|
case 1: return weight1;
|
|
case 2: return weight2;
|
|
case 3: return weight3;
|
|
default: return -1;
|
|
}
|
|
}
|
|
|
|
public BoneWeight(int index0, int index1, int index2, int index3, float weight0, float weight1, float weight2, float weight3)
|
|
{
|
|
this.index0 = index0;
|
|
this.index1 = index1;
|
|
this.index2 = index2;
|
|
this.index3 = index3;
|
|
this.weight0 = weight0;
|
|
this.weight1 = weight1;
|
|
this.weight2 = weight2;
|
|
this.weight3 = weight3;
|
|
}
|
|
|
|
public bool Equals(BoneWeight other)
|
|
{
|
|
return index0 == other.index0
|
|
&& index1 == other.index1
|
|
&& index2 == other.index2
|
|
&& index3 == other.index3
|
|
&& weight0 == other.weight0
|
|
&& weight1 == other.weight1
|
|
&& weight2 == other.weight2
|
|
&& weight3 == other.weight3;
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
unchecked
|
|
{
|
|
int hash = 17;
|
|
hash = hash * 31 + index0;
|
|
hash = hash * 31 + index1;
|
|
hash = hash * 31 + index2;
|
|
hash = hash * 31 + index3;
|
|
hash = hash * 31 + weight0.GetHashCode();
|
|
hash = hash * 31 + weight1.GetHashCode();
|
|
hash = hash * 31 + weight2.GetHashCode();
|
|
hash = hash * 31 + weight3.GetHashCode();
|
|
return hash;
|
|
}
|
|
}
|
|
|
|
public unsafe BoneWeight Interpolate(BoneWeight other, double ratio)
|
|
{
|
|
BoneWeight boneWeightA = this;
|
|
BoneWeight boneWeightB = other;
|
|
|
|
Dictionary<int, float> newBoneWeight = new Dictionary<int, float>();
|
|
|
|
// Map weights and indices
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
newBoneWeight.TryAdd(boneWeightA.GetIndex(i), 0);
|
|
newBoneWeight.TryAdd(boneWeightB.GetIndex(i), 0);
|
|
newBoneWeight[boneWeightA.GetIndex(i)] += (float)((1 - ratio) * boneWeightA.GetWeight(i));
|
|
newBoneWeight[boneWeightB.GetIndex(i)] += (float)(ratio * boneWeightB.GetWeight(i));
|
|
}
|
|
|
|
int* newIndices = stackalloc int[4];
|
|
float* newWeights = stackalloc float[4];
|
|
|
|
// Order from biggest to smallest weight, and drop bones above 4th
|
|
float totalWeight = 0;
|
|
int k = 0;
|
|
foreach (KeyValuePair<int, float> boneWeightN in newBoneWeight.OrderByDescending(x => x.Value))
|
|
{
|
|
newIndices[k] = boneWeightN.Key;
|
|
newWeights[k] = boneWeightN.Value;
|
|
totalWeight += boneWeightN.Value;
|
|
if (k == 3)
|
|
break;
|
|
k++;
|
|
}
|
|
|
|
var sumA = boneWeightA.weight0 + boneWeightA.weight1 + boneWeightA.weight2 + boneWeightA.weight3;
|
|
var sumB = boneWeightB.weight0 + boneWeightB.weight1 + boneWeightB.weight2 + boneWeightB.weight3;
|
|
var targetSum = (float)((1d - ratio) * sumA + ratio * sumB);
|
|
|
|
// Normalize and re-scale to preserve original weight sum.
|
|
if (totalWeight > 0f)
|
|
{
|
|
var scale = targetSum / totalWeight;
|
|
for (int j = 0; j < 4; j++)
|
|
{
|
|
newWeights[j] *= scale;
|
|
}
|
|
}
|
|
|
|
return new BoneWeight(
|
|
newIndices[0], newIndices[1], newIndices[2], newIndices[3],
|
|
newWeights[0], newWeights[1], newWeights[2], newWeights[3]);
|
|
|
|
//return new BoneWeight(
|
|
// ratio < 0.5f ? index0 : other.index0,
|
|
// ratio < 0.5f ? index1 : other.index1,
|
|
// ratio < 0.5f ? index2 : other.index2,
|
|
// ratio < 0.5f ? index3 : other.index3,
|
|
// (float)(ratio * weight0 + (1 - ratio) * other.weight0),
|
|
// (float)(ratio * weight1 + (1 - ratio) * other.weight1),
|
|
// (float)(ratio * weight2 + (1 - ratio) * other.weight2),
|
|
// (float)(ratio * weight3 + (1 - ratio) * other.weight3));
|
|
}
|
|
}
|
|
}
|