Code/HumanoidRetargeter/Core/Formats/Mmd/Bullet/BulletDynamics/SolverConstraint.cs

A plain data container used by the physics solver port of Bullet. It stores contact and constraint state for a solver row, including contact normals, relative positions, angular components, impulse accumulators, limits and references to the two solver bodies.

Native Interop
/*
 * C# / XNA  port of Bullet (c) 2011 Mark Neale <[email protected]>
 *
 * Bullet Continuous Collision Detection and Physics Library
 * Copyright (c) 2003-2008 Erwin Coumans  http://www.bulletphysics.com/
 *
 * This software is provided 'as-is', without any express or implied warranty.
 * In no event will the authors be held liable for any damages arising from
 * the use of this software.
 *
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
 *
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
 *    appreciated but is not required.
 * 2. Altered source versions must be plainly marked as such, and must not be
 *    misrepresented as being the original software.
 * 3. This notice may not be removed or altered from any source distribution.
 */
// Adapted from BulletXNA 73b2e1b9: namespace isolation, no XNA rendering, one type per file.
#nullable disable
#pragma warning disable CS1591, CS0168, CS0219, CS0414, CS0660, CS0661, CS0659, CS0693, CS8981, CS0108, CS0114
using System.IO;
using HumanoidRetargeter.Core.Formats.Mmd.Bullet.BulletCollision;
using HumanoidRetargeter.Core.Formats.Mmd.Bullet.LinearMath;

namespace HumanoidRetargeter.Core.Formats.Mmd.Bullet.BulletDynamics;

internal class SolverConstraint
{
	public IndexedVector3 m_relpos1CrossNormal;
	public IndexedVector3 m_contactNormal;
	public IndexedVector3 m_relpos2CrossNormal;
	public IndexedVector3 m_angularComponentA;
	public IndexedVector3 m_angularComponentB;
	public float m_appliedPushImpulse;
	public float m_appliedImpulse;
	public float m_friction;
	public float m_jacDiagABInv;
	public int m_numConsecutiveRowsPerKernel;
	public int m_frictionIndex;
	// warning - these are unioned in the c++ version
	public RigidBody m_solverBodyA;
	public int m_companionIdA;
	// warning - these are unioned in the c++ version
	public RigidBody m_solverBodyB;
	public int m_companionIdB;
	//public TypedConstraint m_originalContactPointConstraint;
	//public ManifoldPoint m_originalContactPoint;
	public object m_originalContactPoint;
	public float m_rhs;
	public float m_cfm;
	public float m_lowerLimit;
	public float m_upperLimit;
	public float m_rhsPenetration;
	public int m_overrideNumSolverIterations = -1;
	public SolverConstraint()
	{
		int i = 0;
	}

	public void Reset()
	{
		m_relpos1CrossNormal = IndexedVector3.Zero;
		m_contactNormal = IndexedVector3.Zero;
		m_relpos2CrossNormal = IndexedVector3.Zero;
		m_angularComponentA = IndexedVector3.Zero;
		m_angularComponentB = IndexedVector3.Zero;
		m_appliedPushImpulse = 0f;
		m_appliedImpulse = 0f;
		m_friction = 0f;
		m_jacDiagABInv = 0f;
		m_numConsecutiveRowsPerKernel = 0;
		m_frictionIndex = 0;
		m_solverBodyA = null;
		m_companionIdA = 0;
		m_solverBodyB = null;
		m_companionIdB = 0;
		m_originalContactPoint = null;
		//m_originalContactPointConstraint = null;
		m_rhs = 0f;
		m_cfm = 0;
		m_lowerLimit = 0f;
		m_upperLimit = 0f;
		m_rhsPenetration = 0f;
		m_overrideNumSolverIterations = -1;
	}
}