///////////////////////////////////////////////////////////////////////////////// // SoftBody implementation SoftBody::SoftBody( Bool bStatic, ShapeDeformable * pLocalShape, SoftBodyEnvironment * pEnvironment, const Vertex3 & vPosition, const Quaternion & qOrientation, const Vector3 & vLinearSpeed, const Vector3 & vAngularSpeed ): BodyNode( bStatic, pLocalShape, 1.0f, vPosition, qOrientation, vLinearSpeed, vAngularSpeed ), m_arrMaterials() //m_arrClusters(), m_hClusterTree(), m_arrClusterConnectivity() { // SoftBody environment m_pEnvironment = pEnvironment; // Shape data m_pDeformableShape = (ShapeDeformable*)m_pLocalShape; // Physical properties m_iAeroDynamicsModel = SOFTBODY_AERODYNAMICS_V_Point; m_fDrag = 0.0f; m_fLift = 0.0f; m_fPressure = 0.0f; m_fVolumeConversation = 0.0f; //m_fDynamicFriction = 0.2f; m_arrMaterials.UseMemoryContext( PhysicsFn->GetMemoryContext(), TEXT("SoftBodies") ); m_arrMaterials.Create(); // Pose-Matching m_hPose.arrDeltas.UseMemoryContext( PhysicsFn->GetMemoryContext(), TEXT("SoftBodies") ); m_hPose.arrDeltas.Create(); m_hPose.arrWeights.UseMemoryContext( PhysicsFn->GetMemoryContext(), TEXT("SoftBodies") ); m_hPose.arrWeights.Create(); m_hPose.bIsVolume = false; m_hPose.bIsFrame = false; m_hPose.fVolume = 0.0f; m_hPose.matBaseScaling = Matrix3::Identity; m_hPose.vCenterOfMass = Vertex3::Null; m_hPose.matRotation = Matrix3::Identity; m_hPose.matScaling = Matrix3::Identity; m_fPoseMatching = 0.0f; m_fMaxVolumeRatio = 1.0f; // Default material Material * pMaterial = PushMaterial(); pMaterial->fLinearStiffness = 1.0f; pMaterial->fAngularStiffness = 1.0f; pMaterial->fAreaStiffness = 1.0f; pMaterial->fVolumeStiffness = 1.0f; pMaterial->dwFlags = 0; }
void PushVector(const std::vector<T*> array) { totle_weight_ = 0.0; ptr_array_.clear(); bool is_not_overflow = true; int length = array.size(); int* elements = new int[length]; std::vector< xxcig::shared_ptr<SmartBag> > bag_array; for (int i = 0; i < length; ++i) { elements[i] = 1; std::vector<int> selectors(elements, elements + length); do { xxcig::shared_ptr<SmartBag> new_bag(new SmartBag(capacity_, param_function_)); for (size_t j = 0; j < selectors.size(); ++j) { if (1 == selectors[j]) { is_not_overflow = new_bag->PushMaterial(array[j]); } } if (new_bag->Size() > 0) { bag_array.push_back(new_bag); } } while (prev_permutation(selectors.begin(), selectors.end())); sort(bag_array.begin(), bag_array.end(), SmartBag::CompareBag); while (bag_array.size() > 1) { bag_array.pop_back(); // only leave the largest one } if (!is_not_overflow) { break; } } delete[] elements; if (bag_array.size() > 0) { for (int k = 0; k < bag_array.front()->Size(); ++k) { PushMaterial(bag_array.front()->GetMaterial(k)); } } }