/* ----------------------------------------------------------------------------- This source file is part of GIMPACT Library. For the latest info, see http://gimpact.sourceforge.net/ Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371. email: projectileman@yahoo.com This library is free software; you can redistribute it and/or modify it under the terms of EITHER: (1) The GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The text of the GNU Lesser General Public License is included with this library in the file GIMPACT-LICENSE-LGPL.TXT. (2) The BSD-style license that is included with this library in the file GIMPACT-LICENSE-BSD.TXT. (3) The zlib/libpng license that is included with this library in the file GIMPACT-LICENSE-ZLIB.TXT. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details. ----------------------------------------------------------------------------- */ #include "gim_contact.h" #define MAX_COINCIDENT 8 void gim_contact_array::merge_contacts( const gim_contact_array & contacts, bool normal_contact_average) { clear(); if(contacts.size()==1) { push_back(contacts.back()); return; } gim_array keycontacts(contacts.size()); keycontacts.resize(contacts.size(),false); //fill key contacts GUINT i; for (i = 0;im_depth - CONTACT_DIFF_EPSILON > scontact->m_depth)//) { *pcontact = *scontact; coincident_count = 0; } else if(normal_contact_average) { if(btFabs(pcontact->m_depth - scontact->m_depth)m_normal; coincident_count++; } } } } else {//add new contact if(normal_contact_average && coincident_count>0) { pcontact->interpolate_normals(coincident_normals,coincident_count); coincident_count = 0; } push_back(*scontact); pcontact = &back(); } last_key = key; } } void gim_contact_array::merge_contacts_unique(const gim_contact_array & contacts) { clear(); if(contacts.size()==1) { push_back(contacts.back()); return; } GIM_CONTACT average_contact = contacts.back(); for (GUINT i=1;i