Git Product home page Git Product logo

Comments (4)

pafuhana1213 avatar pafuhana1213 commented on August 30, 2024

Hi,
I tried it but this issue did not occur.
Would you please share with me how to repro it?

thanks

from kawaiiphysics.

sergi-gonzalez avatar sergi-gonzalez commented on August 30, 2024

Hi @pafuhana1213 ,

First of all, our team loves Kawaii Physics, thanks a lot for sharing your work.

I am testing the plugin on UE5 and I got the same crash in the same place:
CalcBoneLength(ModifyBones[0], Bones);
\Plugins\KawaiiPhysics\Source\KawaiiPhysics\Private\AnimNode_KawaiiPhysics.cpp LN 200

I have investigated the problem and the crash happens because Bone.BoneRef.BoneIndex is greater than the number of transforms in RefBonePose.
In our case LOD0 has 140 bones and LOD2 has 78 bones. The crash happened when InitModifyBones is called when BoneContainer.CalculatedForLOD is 2 and one modify bone had the boneIndex 90 (RefBonePose contains 78 entries).

The following fix seems to work as expected (changes tagged with [hexworks]):

void FAnimNode_KawaiiPhysics::CalcBoneLength(FKawaiiPhysicsModifyBone& Bone, const TArray<FTransform>& RefBonePose, const FBoneContainer& BoneContainer)//[hexworks] - Added BoneContainer
{
	if (Bone.ParentIndex < 0)
	{
		Bone.LengthFromRoot = 0.0f;
	}
	else
	{
		if (!Bone.bDummy)
		{
			FCompactPoseBoneIndex CompactPoseBoneIndex = Bone.BoneRef.GetCompactPoseIndex(BoneContainer);//[hexworks] - Fix crash indexing Bone.BoneRef.BoneIndex
			Bone.LengthFromRoot = ModifyBones[Bone.ParentIndex].LengthFromRoot
				+ RefBonePose[CompactPoseBoneIndex.GetInt()].GetLocation().Size();//[hexworks] - Fix crash indexing Bone.BoneRef.BoneIndex
		}
		else
		{
			Bone.LengthFromRoot = ModifyBones[Bone.ParentIndex].LengthFromRoot + DummyBoneLength;
		}
		
		TotalBoneLength = FMath::Max(TotalBoneLength, Bone.LengthFromRoot);
	}

	for (int ChildIndex : Bone.ChildIndexs)
	{
		CalcBoneLength(ModifyBones[ChildIndex], RefBonePose, BoneContainer);//[hexworks] - Added BoneContainer
	}
}

It's also required to fix the lines that call CalcBoneLength adding BoneContainer as last parameter.
Could you please check the fix and integrate it in the repo?

Best regards,

sergi

from kawaiiphysics.

taka1arg avatar taka1arg commented on August 30, 2024

お疲れ様です。

私の方でも配列のオーバーランが発生し
CalcBoneLength(ModifyBones[0], BoneContainer.GetRefPoseArray());
に変更して対応しました。

レベル起動後にスケルタルメッシュをカメラの遠く(LODが適用される距離)にスポーンすると発生ように思われます。

from kawaiiphysics.

pafuhana1213 avatar pafuhana1213 commented on August 30, 2024

Hi guys,
Sorry for my late reply...
I succeeded to repro this issue on UE5.1 and committed a9bf985 to fix this now.

thanks!

from kawaiiphysics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.