2008-06-18 06:46:49 +00:00
|
|
|
/**
|
2008-06-18 07:03:47 +00:00
|
|
|
* $Id$
|
2008-06-18 06:46:49 +00:00
|
|
|
*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-06-18 06:46:49 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2010-09-15 16:13:32 +00:00
|
|
|
#if defined(WIN32) && !defined(FREE_WINDOWS)
|
2008-06-18 06:46:49 +00:00
|
|
|
#pragma warning (disable : 4786)
|
|
|
|
#endif //WIN32
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
#include "BL_ShapeDeformer.h"
|
|
|
|
#include "GEN_Map.h"
|
|
|
|
#include "STR_HashedString.h"
|
|
|
|
#include "RAS_IPolygonMaterial.h"
|
2009-11-24 22:44:29 +00:00
|
|
|
#include "RAS_MeshObject.h"
|
2008-06-18 06:46:49 +00:00
|
|
|
|
|
|
|
//#include "BL_ArmatureController.h"
|
|
|
|
#include "DNA_armature_types.h"
|
|
|
|
#include "DNA_action_types.h"
|
|
|
|
#include "DNA_key_types.h"
|
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
#include "DNA_meshdata_types.h"
|
2008-06-24 22:19:00 +00:00
|
|
|
#include "DNA_ipo_types.h"
|
|
|
|
#include "DNA_curve_types.h"
|
2008-06-18 06:46:49 +00:00
|
|
|
#include "BKE_armature.h"
|
|
|
|
#include "BKE_action.h"
|
|
|
|
#include "BKE_key.h"
|
2008-06-24 22:19:00 +00:00
|
|
|
#include "BKE_ipo.h"
|
2008-06-18 06:46:49 +00:00
|
|
|
#include "MT_Point3.h"
|
|
|
|
|
|
|
|
extern "C"{
|
|
|
|
#include "BKE_lattice.h"
|
|
|
|
}
|
|
|
|
#include "BKE_utildefines.h"
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2008-06-18 06:46:49 +00:00
|
|
|
|
|
|
|
#define __NLA_DEFNORMALS
|
|
|
|
//#undef __NLA_DEFNORMALS
|
|
|
|
|
|
|
|
|
|
|
|
BL_ShapeDeformer::~BL_ShapeDeformer()
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
2009-06-08 20:08:19 +00:00
|
|
|
RAS_Deformer *BL_ShapeDeformer::GetReplica()
|
2008-06-18 06:46:49 +00:00
|
|
|
{
|
|
|
|
BL_ShapeDeformer *result;
|
|
|
|
|
|
|
|
result = new BL_ShapeDeformer(*this);
|
|
|
|
result->ProcessReplica();
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BL_ShapeDeformer::ProcessReplica()
|
|
|
|
{
|
2009-06-08 20:08:19 +00:00
|
|
|
BL_SkinDeformer::ProcessReplica();
|
|
|
|
m_lastShapeUpdate = -1;
|
2008-06-18 06:46:49 +00:00
|
|
|
}
|
|
|
|
|
2008-06-24 22:19:00 +00:00
|
|
|
bool BL_ShapeDeformer::LoadShapeDrivers(Object* arma)
|
|
|
|
{
|
|
|
|
IpoCurve *icu;
|
|
|
|
|
|
|
|
m_shapeDrivers.clear();
|
|
|
|
// check if this mesh has armature driven shape keys
|
2009-06-08 20:08:19 +00:00
|
|
|
if (m_bmesh->key && m_bmesh->key->ipo) {
|
2008-06-24 22:19:00 +00:00
|
|
|
for(icu= (IpoCurve*)m_bmesh->key->ipo->curve.first; icu; icu= (IpoCurve*)icu->next) {
|
|
|
|
if(icu->driver &&
|
|
|
|
(icu->flag & IPO_MUTE) == 0 &&
|
|
|
|
icu->driver->type == IPO_DRIVER_TYPE_NORMAL &&
|
|
|
|
icu->driver->ob == arma &&
|
|
|
|
icu->driver->blocktype == ID_AR) {
|
|
|
|
// this shape key ipo curve has a driver on the parent armature
|
|
|
|
// record this curve in the shape deformer so that the corresponding
|
|
|
|
m_shapeDrivers.push_back(icu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return !m_shapeDrivers.empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BL_ShapeDeformer::ExecuteShapeDrivers(void)
|
|
|
|
{
|
|
|
|
if (!m_shapeDrivers.empty() && PoseUpdated()) {
|
|
|
|
vector<IpoCurve*>::iterator it;
|
2009-08-19 10:26:43 +00:00
|
|
|
// void *poin;
|
|
|
|
// int type;
|
2008-09-17 01:29:54 +00:00
|
|
|
|
2008-07-16 21:24:54 +00:00
|
|
|
// the shape drivers use the bone matrix as input. Must
|
|
|
|
// update the matrix now
|
|
|
|
m_armobj->ApplyPose();
|
|
|
|
|
2008-06-24 22:19:00 +00:00
|
|
|
for (it=m_shapeDrivers.begin(); it!=m_shapeDrivers.end(); it++) {
|
|
|
|
// no need to set a specific time: this curve has a driver
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
// XXX IpoCurve *icu = *it;
|
|
|
|
//calc_icu(icu, 1.0f);
|
|
|
|
//poin = get_ipo_poin((ID*)m_bmesh->key, icu, &type);
|
|
|
|
//if (poin)
|
|
|
|
// write_ipo_poin(poin, type, icu->curval);
|
2008-06-24 22:19:00 +00:00
|
|
|
}
|
2008-09-17 01:29:54 +00:00
|
|
|
|
2008-06-24 22:19:00 +00:00
|
|
|
ForceUpdate();
|
2008-09-17 01:29:54 +00:00
|
|
|
m_armobj->RestorePose();
|
2009-06-08 20:08:19 +00:00
|
|
|
m_bDynamic = true;
|
2008-06-24 22:19:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-06-18 06:46:49 +00:00
|
|
|
bool BL_ShapeDeformer::Update(void)
|
|
|
|
{
|
|
|
|
bool bShapeUpdate = false;
|
|
|
|
bool bSkinUpdate = false;
|
|
|
|
|
2008-06-24 22:19:00 +00:00
|
|
|
ExecuteShapeDrivers();
|
|
|
|
|
2008-06-18 06:46:49 +00:00
|
|
|
/* See if the object shape has changed */
|
|
|
|
if (m_lastShapeUpdate != m_gameobj->GetLastFrame()) {
|
|
|
|
/* the key coefficient have been set already, we just need to blend the keys */
|
|
|
|
Object* blendobj = m_gameobj->GetBlendObject();
|
|
|
|
|
|
|
|
// make sure the vertex weight cache is in line with this object
|
|
|
|
m_pMeshObject->CheckWeightCache(blendobj);
|
|
|
|
|
2009-10-22 09:31:07 +00:00
|
|
|
/* we will blend the key directly in m_transverts array: it is used by armature as the start position */
|
2009-06-08 20:08:19 +00:00
|
|
|
/* m_bmesh->key can be NULL in case of Modifier deformer */
|
|
|
|
if (m_bmesh->key) {
|
2009-10-22 09:31:07 +00:00
|
|
|
/* store verts locally */
|
|
|
|
VerifyStorage();
|
|
|
|
|
2009-10-22 16:35:51 +00:00
|
|
|
do_rel_key(0, m_bmesh->totvert, m_bmesh->totvert, (char *)(float *)m_transverts, m_bmesh->key, NULL, 0);
|
2009-06-08 20:08:19 +00:00
|
|
|
m_bDynamic = true;
|
|
|
|
}
|
2008-06-18 06:46:49 +00:00
|
|
|
|
|
|
|
// Don't release the weight array as in Blender, it will most likely be reusable on next frame
|
|
|
|
// The weight array are ultimately deleted when the skin mesh is destroyed
|
|
|
|
|
|
|
|
/* Update the current frame */
|
|
|
|
m_lastShapeUpdate=m_gameobj->GetLastFrame();
|
|
|
|
|
|
|
|
// As we have changed, the mesh, the skin deformer must update as well.
|
|
|
|
// This will force the update
|
|
|
|
BL_SkinDeformer::ForceUpdate();
|
|
|
|
bShapeUpdate = true;
|
|
|
|
}
|
|
|
|
// check for armature deform
|
2009-10-22 09:31:07 +00:00
|
|
|
bSkinUpdate = BL_SkinDeformer::UpdateInternal(bShapeUpdate && m_bDynamic);
|
2008-06-18 06:46:49 +00:00
|
|
|
|
2009-06-08 20:08:19 +00:00
|
|
|
// non dynamic deformer = Modifer without armature and shape keys, no need to create storage
|
|
|
|
if (!bSkinUpdate && bShapeUpdate && m_bDynamic) {
|
2009-10-22 09:31:07 +00:00
|
|
|
// this means that there is no armature, we still need to
|
|
|
|
// update the normal (was not done after shape key calculation)
|
2008-06-18 06:46:49 +00:00
|
|
|
|
2008-06-19 14:40:46 +00:00
|
|
|
#ifdef __NLA_DEFNORMALS
|
2009-06-08 20:08:19 +00:00
|
|
|
if (m_recalcNormal)
|
|
|
|
RecalcNormals();
|
2008-06-19 14:40:46 +00:00
|
|
|
#endif
|
2008-06-18 06:46:49 +00:00
|
|
|
bSkinUpdate = true;
|
|
|
|
}
|
|
|
|
return bSkinUpdate;
|
|
|
|
}
|