Code Monkey home page Code Monkey logo

Comments (11)

 avatar commented on July 23, 2024

UPDATE:
A similar problem occurs with the cloth, when using more than one custom mesh
EDIT: MyCustomCloth file removed.
both meshes, if applied in separate sample Scenes work fine, but together they fail.
They are exactly build with the same logic. And all "g_buffers->..." accesses are made relative, so that those both cloth meshes simply should be appended. The only dependency is, that they must be done first in a scene yet, but in this sample there's no other object which could influence them.
But they are both disturbed yet.
UPDATE 2: solved.

from flex.

mmacklin avatar mmacklin commented on July 23, 2024

I think the problem here is probably due to the fact that the indices are note correctly offset:

g_buffers->springIndices.push_back(mCloth->springIndices[i]);

For the second cloth the indices need to be shifted by the number of particles in the first cloth. So before adding particles for the second cloth, record the current number of particles, e.g.:

int particleOffset = g_buffers->positions.size();

Then, when adding indices for the second cloth:

for (int i = 0; i < numsprings * 2; ++i)
   g_buffers->springIndices.push_back(mCloth->springIndices[i] + particleOffset);

from flex.

 avatar commented on July 23, 2024

Thanks You Miles @mmacklin for your answer.
As you suggested, I added "start_cloth_index":

g_buffers->triangles.push_back(mesh->m_indices[i] + start_cloth_index);
g_buffers->springIndices.push_back(mCloth->springIndices[i] + start_cloth_index); 

And finally it works! Great! My updated code was wrong. Thank you for the help.
(I removed the MyCustomCloth file in the post cause of that invalid part)

However, it still fails in the Bath Dam scene. So I will again investigate the "Fluid Cloth Coupling Goo" Scene, which works fine for cloth and water interaction. There adding adhesion works fine, too.
UPDATE: solved.

I also noticed a loop in the "Voxelize" function in voxelize.cpp which can cause a very high time penalty, if the mesh of a soft body object has a different topology. So I limited the rays for each voxel to 10.
Do you know a better threshold for this?

from flex.

 avatar commented on July 23, 2024

I debugged the original scenes.
On "Soft Bowl" "Soft Rod", "Soft Armadillo", "Soft Bunny", "Plastic Bunnies"
during the call to "NvFlexSetRigids" this error can occur:

D3D11 ERROR: ID3D11DeviceContext::Dispatch: The Unordered Access View in slot 0 of the Compute Shader unit has structure stride 16 while the shader expects a structure stride of 4. This mismatch is invalid if the shader actually uses the view (e.g. it is not skipped due to shader code branching). [ EXECUTION ERROR #2097378: DEVICE_UNORDEREDACCESSVIEW_STRUCTURE_STRIDE_MISMATCH]

Sometimes before warm up additionally this error can occur:

D3D11 ERROR: ID3D11DeviceContext::CopySubresourceRegion: pSrcBox is not a valid box for the source subresource. *pSrcBox = { left:0, top:0, front:0, right:180912, bottom:1, back:1 }. SrcSubresource = { left:0, top:0, front:0, right:86272, bottom:1, back:1 }. [ RESOURCE_MANIPULATION ERROR #280: COPYSUBRESOURCEREGION_INVALIDSOURCEBOX]

However, that seems only affect soft-bodies, nothing else. Visually I see no error, so maybe it is only missing data through the initialization process, which means nothing. On Cloth objects this does not occur.

UPDATE: solved.

from flex.

mmacklin avatar mmacklin commented on July 23, 2024

We fixed this in the 1.2.0 beta release (available now).

from flex.

 avatar commented on July 23, 2024

thanks, I upgraded my project, which uses Flex to operate with the new version.

from flex.

 avatar commented on July 23, 2024

I found out: g_params.numIterations = 3; is tearing the custom cloth.
Also g_numSubsteps = 1 can cause this.
When changing the "Num Iterations" slider in the original "Tearing" sample down to a value lower than 4 it disturbs the cloth.
(In the "Potpourri" Scene a value of 1 works for that, although there's also cloth)
So I set these always to 4 or more (mostly 7).

high increasing adhesion in Bath Dam + Paragliding Scene disturbs everything

from flex.

 avatar commented on July 23, 2024

using the AddTriangleMesh() function to build collision constraints works great with soft bodies,
and I got custom cloth and Bouyancy water interaction also working with g_params.numIterations = 7
custom cloth in Bunny Bath Dam Scene with:
g_params.relaxationFactor = 1.0f;
g_params.relaxationMode = eNvFlexRelaxationLocal;

UPDATE: I found out, that g_buffers->rigidTranslations receives wrong values, cause
CalculateRigidCentersOfMass is never called in the case, when soft bodies are active, cause
g_buffers->rigidTranslations.size() is non-zeo after soft bodies were done.

So in main.cpp in function void Init(int scene, bool centerCamera = true) I changed;

	if (g_buffers->rigidTranslations.size() == 0)
	{
	     g_buffers->rigidTranslations.resize(g_buffers->rigidOffsets.size() - 1, Vec3());
	     CalculateRigidCentersOfMass(...
	}

to:

	int rigidTranslations = g_buffers->rigidTranslations.size();
	if (rigidTranslations != numRigids)  // to ensure ANY changes (if soft body already present)
        {
            g_buffers->rigidTranslations.resize(g_buffers->rigidOffsets.size() - 1, Vec3());
            CalculateRigidCentersOfMass(....
	}

So all these combinations work in my tests:

  • Custom Cloth + Bouyancy Fluid + Soft Bodys + Triangle Collision Constraint + Rigid bodies
  • Custom Cloth + Bouyancy Fluid + Rigid Bodys + Triangle Collision Constraint (without soft bodies)
  • Custom Cloth + Bath Dam Fluid + Soft Body + Triangle Collision Constraint + Rigid Bodies
  • Custom Cloth + Bath Dam Fluid + Rigid Body + Triangle Collision Constraint (without soft bodies)

Still issue here:

  • Custom Cloth + Paragliding Bunny Scene ok, but the original cloth there fails now, which is not important for me, so I consider this as solved.

Additionally I will use NVIDIA Blast to also have the destruction capabilities. All results from that data will then be added as collision constraints in Flex.

UPDATE: The soft body and rigid body interaction issue seems to be solved.
And I think the general "custom cloth" and fluid interaction issue is also solved now.

from flex.

 avatar commented on July 23, 2024

I think most of my issues are solved now. Flex is really great!
It would be great to have local settings of adhesion and other fluid related properties on each "group".
So different fluids then could be done within one scene.
Is it possible to switch adhesion off on solid particles only? This at least would solve some interaction issues.

from flex.

 avatar commented on July 23, 2024

UPDATED: solved
now using DXUT CFirstPersonCamera works for me in both ways for Rendering Fluid:

  1. through building RH Matrices with functions of Flex:
	g_camPos.x = camX;
	g_camPos.y = camY;
	g_camPos.z = -camZ;  // D3D LH to RH

	g_camAngle.x = -yaw;   // to RH   (yaw in FirstPersonCamera is Y angle)
	g_camAngle.y = -pitch; // to RH   (pitch in FirstPersonCamera is X angle)
	g_camAngle.z = -roll;    // to RH   (roll in FirstPersonCamera is Z angle)

  1. through using directly "LHprojection" and "LHview" matrices from DXUT CFirstPersonCamera:
	Vec4 c1, c2, c3, c4;

	// apply projection LH MAJOR ROW as MAJOR COLUMN matrix:
	c1 = Vec4(LHprojection->_11, LHprojection->_12, LHprojection->_13, LHprojection->_14);
	c2 = Vec4(LHprojection->_21, LHprojection->_22, LHprojection->_23, LHprojection->_24);
	c3 = Vec4(LHprojection->_31, LHprojection->_32, LHprojection->_33, LHprojection->_34);
	c4 = Vec4(LHprojection->_41, LHprojection->_42, LHprojection->_43, LHprojection->_44);
	proj = Matrix44(c1, c2, c3, c4);

	// apply view LH MAJOR ROW as MAJOR COLUMN matrix:
	c1 = Vec4(LHview->_11, LHview->_12, LHview->_13, LHview->_14);
	c2 = Vec4(LHview->_21, LHview->_22, LHview->_23, LHview->_24);
	c3 = Vec4(LHview->_31, LHview->_32, LHview->_33, LHview->_34);
	c4 = Vec4(LHview->_41, LHview->_42, LHview->_43, LHview->_44);
	view = Matrix44(c1, c2, c3, c4);

	// LH ro RH rotation
	view.columns[0][2]=-view.columns[0][2];
	view.columns[1][2]=-view.columns[1][2];
	view.columns[2][0]=-view.columns[2][0];
	view.columns[2][1]=-view.columns[2][1];

	// LH to RH translation
	view.columns[3][2]=-view.columns[3][2]; 

	// LH to RH projection
	proj.columns[2][2] = -proj.columns[2][2];
	proj.columns[2][3] = -proj.columns[2][3];

and in DemoContextD3D11::setView() I simply removed ConvertToD3DProjection

These Matrix transforms work for me; however I'm always interested if you find any error within it.

from flex.

 avatar commented on July 23, 2024

All solved so far. Flex is great!

from flex.

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.