2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* 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
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* 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.
|
2002-10-12 11:37:38 +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.
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
2011-02-25 13:30:41 +00:00
|
|
|
/** \file gameengine/Converter/BL_ArmatureObject.cpp
|
|
|
|
* \ingroup bgeconv
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BL_ArmatureObject.h"
|
|
|
|
#include "BL_ActionActuator.h"
|
2013-08-14 23:31:49 +00:00
|
|
|
#include "BL_Action.h"
|
2009-09-24 21:22:24 +00:00
|
|
|
#include "KX_BlenderSceneConverter.h"
|
2010-08-16 05:46:10 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BLI_blenlib.h"
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
#include "BLI_ghash.h"
|
2009-09-24 21:22:24 +00:00
|
|
|
#include "BIK_api.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_action.h"
|
|
|
|
#include "BKE_armature.h"
|
2011-01-07 19:18:31 +00:00
|
|
|
|
2009-09-24 21:22:24 +00:00
|
|
|
#include "BKE_constraint.h"
|
2011-05-06 20:18:42 +00:00
|
|
|
#include "CTR_Map.h"
|
|
|
|
#include "CTR_HashedPtr.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
#include "DNA_action_types.h"
|
2005-04-23 11:36:44 +00:00
|
|
|
#include "DNA_armature_types.h"
|
|
|
|
#include "DNA_object_types.h"
|
2009-06-16 20:38:18 +00:00
|
|
|
#include "DNA_scene_types.h"
|
2009-09-24 21:22:24 +00:00
|
|
|
#include "DNA_constraint_types.h"
|
|
|
|
#include "KX_PythonSeq.h"
|
|
|
|
#include "KX_PythonInit.h"
|
|
|
|
#include "KX_KetsjiEngine.h"
|
2005-04-23 11:36:44 +00:00
|
|
|
|
|
|
|
#include "MT_Matrix4x4.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-09-24 21:22:24 +00:00
|
|
|
/**
|
|
|
|
* Move here pose function for game engine so that we can mix with GE objects
|
|
|
|
* Principle is as follow:
|
2012-05-05 16:03:57 +00:00
|
|
|
* Use Blender structures so that BKE_pose_where_is can be used unchanged
|
2009-09-24 21:22:24 +00:00
|
|
|
* Copy the constraint so that they can be enabled/disabled/added/removed at runtime
|
|
|
|
* Don't copy the constraints for the pose used by the Action actuator, it does not need them.
|
|
|
|
* Scan the constraint structures so that the KX equivalent of target objects are identified and
|
|
|
|
* stored in separate list.
|
|
|
|
* When it is about to evaluate the pose, set the KX object position in the obmat of the corresponding
|
|
|
|
* Blender objects and restore after the evaluation.
|
|
|
|
*/
|
|
|
|
void game_copy_pose(bPose **dst, bPose *src, int copy_constraint)
|
|
|
|
{
|
|
|
|
bPose *out;
|
|
|
|
bPoseChannel *pchan, *outpchan;
|
|
|
|
GHash *ghash;
|
|
|
|
|
|
|
|
/* the game engine copies the current armature pose and then swaps
|
|
|
|
* the object pose pointer. this makes it possible to change poses
|
|
|
|
* without affecting the original blender data. */
|
|
|
|
|
|
|
|
if (!src) {
|
|
|
|
*dst=NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (*dst==src) {
|
2012-05-05 16:03:57 +00:00
|
|
|
printf("BKE_pose_copy_data source and target are the same\n");
|
2009-09-24 21:22:24 +00:00
|
|
|
*dst=NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
out= (bPose*)MEM_dupallocN(src);
|
2010-03-28 20:08:16 +00:00
|
|
|
out->chanhash = NULL;
|
2009-09-24 21:22:24 +00:00
|
|
|
out->agroups.first= out->agroups.last= NULL;
|
|
|
|
out->ikdata = NULL;
|
|
|
|
out->ikparam = MEM_dupallocN(out->ikparam);
|
|
|
|
out->flag |= POSE_GAME_ENGINE;
|
|
|
|
BLI_duplicatelist(&out->chanbase, &src->chanbase);
|
|
|
|
|
|
|
|
/* remap pointers */
|
2010-05-07 07:54:25 +00:00
|
|
|
ghash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "game_copy_pose gh");
|
2009-09-24 21:22:24 +00:00
|
|
|
|
2013-03-18 11:44:56 +00:00
|
|
|
pchan= (bPoseChannel *)src->chanbase.first;
|
|
|
|
outpchan= (bPoseChannel *)out->chanbase.first;
|
2009-09-24 21:22:24 +00:00
|
|
|
for (; pchan; pchan=pchan->next, outpchan=outpchan->next)
|
|
|
|
BLI_ghash_insert(ghash, pchan, outpchan);
|
|
|
|
|
2013-03-18 11:44:56 +00:00
|
|
|
for (pchan = (bPoseChannel *)out->chanbase.first; pchan; pchan = pchan->next) {
|
|
|
|
pchan->parent= (bPoseChannel *)BLI_ghash_lookup(ghash, pchan->parent);
|
|
|
|
pchan->child= (bPoseChannel *)BLI_ghash_lookup(ghash, pchan->child);
|
2009-09-24 21:22:24 +00:00
|
|
|
|
|
|
|
if (copy_constraint) {
|
|
|
|
ListBase listb;
|
|
|
|
// copy all constraint for backward compatibility
|
2012-12-23 11:31:15 +00:00
|
|
|
// BKE_copy_constraints NULLs listb, no need to make extern for this operation.
|
|
|
|
BKE_copy_constraints(&listb, &pchan->constraints, FALSE);
|
2009-09-24 21:22:24 +00:00
|
|
|
pchan->constraints= listb;
|
|
|
|
} else {
|
|
|
|
pchan->constraints.first = NULL;
|
|
|
|
pchan->constraints.last = NULL;
|
|
|
|
}
|
2010-07-23 19:47:25 +00:00
|
|
|
|
|
|
|
// fails to link, props are not used in the BGE yet.
|
2012-03-03 16:31:46 +00:00
|
|
|
#if 0
|
2012-03-24 07:52:14 +00:00
|
|
|
if (pchan->prop)
|
2012-03-03 16:31:46 +00:00
|
|
|
pchan->prop= IDP_CopyProperty(pchan->prop);
|
|
|
|
#endif
|
2010-07-23 19:47:25 +00:00
|
|
|
pchan->prop= NULL;
|
2009-09-24 21:22:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BLI_ghash_free(ghash, NULL, NULL);
|
2010-03-28 20:08:16 +00:00
|
|
|
// set acceleration structure for channel lookup
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_pose_channels_hash_make(out);
|
2009-09-24 21:22:24 +00:00
|
|
|
*dst=out;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Only allowed for Poses with identical channels */
|
2013-08-14 23:31:49 +00:00
|
|
|
void game_blend_poses(bPose *dst, bPose *src, float srcweight, short mode)
|
2011-08-29 06:19:55 +00:00
|
|
|
{
|
2009-09-24 21:22:24 +00:00
|
|
|
bPoseChannel *dchan;
|
|
|
|
const bPoseChannel *schan;
|
|
|
|
bConstraint *dcon, *scon;
|
|
|
|
float dstweight;
|
|
|
|
int i;
|
|
|
|
|
2013-08-14 23:31:49 +00:00
|
|
|
if (mode == BL_Action::ACT_BLEND_BLEND)
|
|
|
|
{
|
|
|
|
dstweight = 1.0f - srcweight;
|
|
|
|
} else if (mode == BL_Action::ACT_BLEND_ADD)
|
|
|
|
{
|
|
|
|
dstweight = 1.0f;
|
|
|
|
} else {
|
|
|
|
dstweight = 1.0f;
|
2009-09-24 21:22:24 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 11:44:56 +00:00
|
|
|
schan= (bPoseChannel *)src->chanbase.first;
|
|
|
|
for (dchan = (bPoseChannel *)dst->chanbase.first; dchan; dchan=(bPoseChannel *)dchan->next, schan= (bPoseChannel *)schan->next) {
|
2009-09-24 21:22:24 +00:00
|
|
|
// always blend on all channels since we don't know which one has been set
|
|
|
|
/* quat interpolation done separate */
|
2009-09-29 01:52:54 +00:00
|
|
|
if (schan->rotmode == ROT_MODE_QUAT) {
|
2009-09-24 21:22:24 +00:00
|
|
|
float dquat[4], squat[4];
|
|
|
|
|
2011-11-06 16:38:21 +00:00
|
|
|
copy_qt_qt(dquat, dchan->quat);
|
|
|
|
copy_qt_qt(squat, schan->quat);
|
2013-08-14 23:31:49 +00:00
|
|
|
if (mode==BL_Action::ACT_BLEND_BLEND)
|
2009-11-10 20:43:45 +00:00
|
|
|
interp_qt_qtqt(dchan->quat, dquat, squat, srcweight);
|
2009-09-24 21:22:24 +00:00
|
|
|
else {
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_fac_qt_fl(squat, srcweight);
|
|
|
|
mul_qt_qtqt(dchan->quat, dquat, squat);
|
2009-09-24 21:22:24 +00:00
|
|
|
}
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_qt(dchan->quat);
|
2009-09-24 21:22:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0; i<3; i++) {
|
|
|
|
/* blending for loc and scale are pretty self-explanatory... */
|
|
|
|
dchan->loc[i] = (dchan->loc[i]*dstweight) + (schan->loc[i]*srcweight);
|
|
|
|
dchan->size[i] = 1.0f + ((dchan->size[i]-1.0f)*dstweight) + ((schan->size[i]-1.0f)*srcweight);
|
|
|
|
|
|
|
|
/* euler-rotation interpolation done here instead... */
|
|
|
|
// FIXME: are these results decent?
|
|
|
|
if (schan->rotmode)
|
|
|
|
dchan->eul[i] = (dchan->eul[i]*dstweight) + (schan->eul[i]*srcweight);
|
|
|
|
}
|
2012-10-14 08:49:01 +00:00
|
|
|
for (dcon= (bConstraint *)dchan->constraints.first, scon= (bConstraint *)schan->constraints.first;
|
|
|
|
dcon && scon;
|
|
|
|
dcon = dcon->next, scon = scon->next)
|
|
|
|
{
|
2009-09-24 21:22:24 +00:00
|
|
|
/* no 'add' option for constraint blending */
|
|
|
|
dcon->enforce= dcon->enforce*(1.0f-srcweight) + scon->enforce*srcweight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this pose is now in src time */
|
|
|
|
dst->ctime= src->ctime;
|
|
|
|
}
|
|
|
|
|
|
|
|
void game_free_pose(bPose *pose)
|
|
|
|
{
|
|
|
|
if (pose) {
|
|
|
|
/* free pose-channels and constraints */
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_pose_channels_free(pose);
|
2009-09-24 21:22:24 +00:00
|
|
|
|
|
|
|
/* free IK solver state */
|
|
|
|
BIK_clear_data(pose);
|
|
|
|
|
|
|
|
/* free IK solver param */
|
|
|
|
if (pose->ikparam)
|
|
|
|
MEM_freeN(pose->ikparam);
|
|
|
|
|
|
|
|
MEM_freeN(pose);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-06 03:46:54 +00:00
|
|
|
BL_ArmatureObject::BL_ArmatureObject(
|
|
|
|
void* sgReplicationInfo,
|
|
|
|
SG_Callbacks callbacks,
|
2009-06-16 20:38:18 +00:00
|
|
|
Object *armature,
|
2011-07-26 06:10:05 +00:00
|
|
|
Scene *scene,
|
|
|
|
int vert_deform_type)
|
2006-01-06 03:46:54 +00:00
|
|
|
|
|
|
|
: KX_GameObject(sgReplicationInfo,callbacks),
|
2009-09-24 21:22:24 +00:00
|
|
|
m_controlledConstraints(),
|
|
|
|
m_poseChannels(),
|
2006-01-06 03:46:54 +00:00
|
|
|
m_objArma(armature),
|
2008-08-31 21:53:39 +00:00
|
|
|
m_framePose(NULL),
|
2012-05-05 16:03:57 +00:00
|
|
|
m_scene(scene), // maybe remove later. needed for BKE_pose_where_is
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
m_lastframe(0.0),
|
2009-09-24 21:22:24 +00:00
|
|
|
m_timestep(0.040),
|
2006-01-06 03:46:54 +00:00
|
|
|
m_activeAct(NULL),
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
m_activePriority(999),
|
2011-09-04 01:42:47 +00:00
|
|
|
m_vert_deform_type(vert_deform_type),
|
2009-09-24 21:22:24 +00:00
|
|
|
m_constraintNumber(0),
|
|
|
|
m_channelNumber(0),
|
2011-09-04 01:42:47 +00:00
|
|
|
m_lastapplyframe(0.0)
|
2006-01-06 03:46:54 +00:00
|
|
|
{
|
2009-01-05 15:48:24 +00:00
|
|
|
m_armature = (bArmature *)armature->data;
|
2006-01-06 03:46:54 +00:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/* we make a copy of blender object's pose, and then always swap it with
|
|
|
|
* the original pose before calling into blender functions, to deal with
|
|
|
|
* replica's or other objects using the same blender object */
|
|
|
|
m_pose = NULL;
|
2009-09-24 21:22:24 +00:00
|
|
|
game_copy_pose(&m_pose, m_objArma->pose, 1);
|
|
|
|
// store the original armature object matrix
|
|
|
|
memcpy(m_obmat, m_objArma->obmat, sizeof(m_obmat));
|
|
|
|
}
|
|
|
|
|
|
|
|
BL_ArmatureObject::~BL_ArmatureObject()
|
|
|
|
{
|
|
|
|
BL_ArmatureConstraint* constraint;
|
|
|
|
while ((constraint = m_controlledConstraints.Remove()) != NULL) {
|
|
|
|
delete constraint;
|
|
|
|
}
|
|
|
|
BL_ArmatureChannel* channel;
|
|
|
|
while ((channel = static_cast<BL_ArmatureChannel*>(m_poseChannels.Remove())) != NULL) {
|
|
|
|
delete channel;
|
|
|
|
}
|
|
|
|
if (m_pose)
|
|
|
|
game_free_pose(m_pose);
|
|
|
|
if (m_framePose)
|
|
|
|
game_free_pose(m_framePose);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BL_ArmatureObject::LoadConstraints(KX_BlenderSceneConverter* converter)
|
|
|
|
{
|
|
|
|
// first delete any existing constraint (should not have any)
|
|
|
|
while (!m_controlledConstraints.Empty()) {
|
|
|
|
BL_ArmatureConstraint* constraint = m_controlledConstraints.Remove();
|
|
|
|
delete constraint;
|
|
|
|
}
|
|
|
|
m_constraintNumber = 0;
|
|
|
|
|
|
|
|
// list all the constraint and convert them to BL_ArmatureConstraint
|
|
|
|
// get the persistent pose structure
|
|
|
|
bPoseChannel* pchan;
|
|
|
|
bConstraint* pcon;
|
|
|
|
bConstraintTypeInfo* cti;
|
|
|
|
Object* blendtarget;
|
|
|
|
KX_GameObject* gametarget;
|
|
|
|
KX_GameObject* gamesubtarget;
|
|
|
|
|
|
|
|
// and locate the constraint
|
2012-10-14 08:49:01 +00:00
|
|
|
for (pchan = (bPoseChannel *)m_pose->chanbase.first; pchan; pchan = pchan->next) {
|
|
|
|
for (pcon = (bConstraint *)pchan->constraints.first; pcon; pcon = pcon->next) {
|
2009-09-24 21:22:24 +00:00
|
|
|
if (pcon->flag & CONSTRAINT_DISABLE)
|
|
|
|
continue;
|
|
|
|
// which constraint should we support?
|
|
|
|
switch (pcon->type) {
|
|
|
|
case CONSTRAINT_TYPE_TRACKTO:
|
2012-03-03 02:47:01 +00:00
|
|
|
case CONSTRAINT_TYPE_DAMPTRACK:
|
2009-09-24 21:22:24 +00:00
|
|
|
case CONSTRAINT_TYPE_KINEMATIC:
|
|
|
|
case CONSTRAINT_TYPE_ROTLIKE:
|
|
|
|
case CONSTRAINT_TYPE_LOCLIKE:
|
|
|
|
case CONSTRAINT_TYPE_MINMAX:
|
|
|
|
case CONSTRAINT_TYPE_SIZELIKE:
|
|
|
|
case CONSTRAINT_TYPE_LOCKTRACK:
|
|
|
|
case CONSTRAINT_TYPE_STRETCHTO:
|
|
|
|
case CONSTRAINT_TYPE_CLAMPTO:
|
|
|
|
case CONSTRAINT_TYPE_TRANSFORM:
|
|
|
|
case CONSTRAINT_TYPE_DISTLIMIT:
|
2011-07-17 20:06:50 +00:00
|
|
|
case CONSTRAINT_TYPE_TRANSLIKE:
|
2012-12-23 11:31:15 +00:00
|
|
|
cti = BKE_constraint_get_typeinfo(pcon);
|
2009-09-24 21:22:24 +00:00
|
|
|
gametarget = gamesubtarget = NULL;
|
|
|
|
if (cti && cti->get_constraint_targets) {
|
|
|
|
ListBase listb = { NULL, NULL };
|
|
|
|
cti->get_constraint_targets(pcon, &listb);
|
|
|
|
if (listb.first) {
|
|
|
|
bConstraintTarget* target = (bConstraintTarget*)listb.first;
|
|
|
|
if (target->tar && target->tar != m_objArma) {
|
|
|
|
// only remember external objects, self target is handled automatically
|
|
|
|
blendtarget = target->tar;
|
|
|
|
gametarget = converter->FindGameObject(blendtarget);
|
|
|
|
}
|
|
|
|
if (target->next != NULL) {
|
|
|
|
// secondary target
|
2012-10-14 08:49:01 +00:00
|
|
|
target = target->next;
|
2009-09-24 21:22:24 +00:00
|
|
|
if (target->tar && target->tar != m_objArma) {
|
|
|
|
// only track external object
|
|
|
|
blendtarget = target->tar;
|
|
|
|
gamesubtarget = converter->FindGameObject(blendtarget);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cti->flush_constraint_targets)
|
|
|
|
cti->flush_constraint_targets(pcon, &listb, 1);
|
|
|
|
}
|
|
|
|
BL_ArmatureConstraint* constraint = new BL_ArmatureConstraint(this, pchan, pcon, gametarget, gamesubtarget);
|
|
|
|
m_controlledConstraints.AddBack(constraint);
|
|
|
|
m_constraintNumber++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BL_ArmatureConstraint* BL_ArmatureObject::GetConstraint(const char* posechannel, const char* constraintname)
|
|
|
|
{
|
|
|
|
SG_DList::iterator<BL_ArmatureConstraint> cit(m_controlledConstraints);
|
|
|
|
for (cit.begin(); !cit.end(); ++cit) {
|
|
|
|
BL_ArmatureConstraint* constraint = *cit;
|
|
|
|
if (constraint->Match(posechannel, constraintname))
|
|
|
|
return constraint;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
BL_ArmatureConstraint* BL_ArmatureObject::GetConstraint(const char* posechannelconstraint)
|
|
|
|
{
|
|
|
|
// performance: use hash string instead of plain string compare
|
|
|
|
SG_DList::iterator<BL_ArmatureConstraint> cit(m_controlledConstraints);
|
|
|
|
for (cit.begin(); !cit.end(); ++cit) {
|
|
|
|
BL_ArmatureConstraint* constraint = *cit;
|
|
|
|
if (!strcmp(constraint->GetName(), posechannelconstraint))
|
|
|
|
return constraint;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
BL_ArmatureConstraint* BL_ArmatureObject::GetConstraint(int index)
|
|
|
|
{
|
|
|
|
SG_DList::iterator<BL_ArmatureConstraint> cit(m_controlledConstraints);
|
|
|
|
for (cit.begin(); !cit.end() && index; ++cit, --index);
|
|
|
|
return (cit.end()) ? NULL : *cit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this function is called to populate the m_poseChannels list */
|
|
|
|
void BL_ArmatureObject::LoadChannels()
|
|
|
|
{
|
|
|
|
if (m_poseChannels.Empty()) {
|
|
|
|
bPoseChannel* pchan;
|
|
|
|
BL_ArmatureChannel* proxy;
|
|
|
|
|
|
|
|
m_channelNumber = 0;
|
2013-03-18 11:44:56 +00:00
|
|
|
for (pchan = (bPoseChannel *)m_pose->chanbase.first; pchan; pchan=(bPoseChannel *)pchan->next) {
|
2009-09-24 21:22:24 +00:00
|
|
|
proxy = new BL_ArmatureChannel(this, pchan);
|
|
|
|
m_poseChannels.AddBack(proxy);
|
|
|
|
m_channelNumber++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BL_ArmatureChannel* BL_ArmatureObject::GetChannel(bPoseChannel* pchan)
|
|
|
|
{
|
|
|
|
LoadChannels();
|
|
|
|
SG_DList::iterator<BL_ArmatureChannel> cit(m_poseChannels);
|
|
|
|
for (cit.begin(); !cit.end(); ++cit)
|
|
|
|
{
|
|
|
|
BL_ArmatureChannel* channel = *cit;
|
|
|
|
if (channel->m_posechannel == pchan)
|
|
|
|
return channel;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
BL_ArmatureChannel* BL_ArmatureObject::GetChannel(const char* str)
|
|
|
|
{
|
|
|
|
LoadChannels();
|
|
|
|
SG_DList::iterator<BL_ArmatureChannel> cit(m_poseChannels);
|
|
|
|
for (cit.begin(); !cit.end(); ++cit)
|
|
|
|
{
|
|
|
|
BL_ArmatureChannel* channel = *cit;
|
|
|
|
if (!strcmp(channel->m_posechannel->name, str))
|
|
|
|
return channel;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
BL_ArmatureChannel* BL_ArmatureObject::GetChannel(int index)
|
|
|
|
{
|
|
|
|
LoadChannels();
|
|
|
|
if (index < 0 || index >= m_channelNumber)
|
|
|
|
return NULL;
|
|
|
|
SG_DList::iterator<BL_ArmatureChannel> cit(m_poseChannels);
|
|
|
|
for (cit.begin(); !cit.end() && index; ++cit, --index);
|
|
|
|
return (cit.end()) ? NULL : *cit;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
2006-01-06 03:46:54 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
CValue* BL_ArmatureObject::GetReplica()
|
|
|
|
{
|
|
|
|
BL_ArmatureObject* replica = new BL_ArmatureObject(*this);
|
2009-06-08 20:08:19 +00:00
|
|
|
replica->ProcessReplica();
|
2002-10-12 11:37:38 +00:00
|
|
|
return replica;
|
|
|
|
}
|
|
|
|
|
2009-06-08 20:08:19 +00:00
|
|
|
void BL_ArmatureObject::ProcessReplica()
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2009-06-08 20:08:19 +00:00
|
|
|
bPose *pose= m_pose;
|
|
|
|
KX_GameObject::ProcessReplica();
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-06-08 20:08:19 +00:00
|
|
|
m_pose = NULL;
|
2009-09-24 21:22:24 +00:00
|
|
|
m_framePose = NULL;
|
2012-09-16 04:58:18 +00:00
|
|
|
game_copy_pose(&m_pose, pose, 1);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2009-09-24 21:22:24 +00:00
|
|
|
void BL_ArmatureObject::ReParentLogic()
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2009-09-24 21:22:24 +00:00
|
|
|
SG_DList::iterator<BL_ArmatureConstraint> cit(m_controlledConstraints);
|
|
|
|
for (cit.begin(); !cit.end(); ++cit) {
|
|
|
|
(*cit)->ReParent(this);
|
|
|
|
}
|
|
|
|
KX_GameObject::ReParentLogic();
|
|
|
|
}
|
|
|
|
|
2011-05-06 20:18:42 +00:00
|
|
|
void BL_ArmatureObject::Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map)
|
2009-09-24 21:22:24 +00:00
|
|
|
{
|
|
|
|
SG_DList::iterator<BL_ArmatureConstraint> cit(m_controlledConstraints);
|
|
|
|
for (cit.begin(); !cit.end(); ++cit) {
|
|
|
|
(*cit)->Relink(obj_map);
|
|
|
|
}
|
|
|
|
KX_GameObject::Relink(obj_map);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BL_ArmatureObject::UnlinkObject(SCA_IObject* clientobj)
|
|
|
|
{
|
|
|
|
// clientobj is being deleted, make sure we don't hold any reference to it
|
|
|
|
bool res = false;
|
|
|
|
SG_DList::iterator<BL_ArmatureConstraint> cit(m_controlledConstraints);
|
|
|
|
for (cit.begin(); !cit.end(); ++cit) {
|
|
|
|
res |= (*cit)->UnlinkObject(clientobj);
|
|
|
|
}
|
|
|
|
return res;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2008-09-17 01:29:54 +00:00
|
|
|
void BL_ArmatureObject::ApplyPose()
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2008-09-17 01:29:54 +00:00
|
|
|
m_armpose = m_objArma->pose;
|
|
|
|
m_objArma->pose = m_pose;
|
2009-09-24 21:22:24 +00:00
|
|
|
// in the GE, we use ctime to store the timestep
|
|
|
|
m_pose->ctime = (float)m_timestep;
|
2009-06-16 20:38:18 +00:00
|
|
|
//m_scene->r.cfra++;
|
2012-03-24 07:52:14 +00:00
|
|
|
if (m_lastapplyframe != m_lastframe) {
|
2009-09-24 21:22:24 +00:00
|
|
|
// update the constraint if any, first put them all off so that only the active ones will be updated
|
|
|
|
SG_DList::iterator<BL_ArmatureConstraint> cit(m_controlledConstraints);
|
|
|
|
for (cit.begin(); !cit.end(); ++cit) {
|
|
|
|
(*cit)->UpdateTarget();
|
|
|
|
}
|
|
|
|
// update ourself
|
|
|
|
UpdateBlenderObjectMatrix(m_objArma);
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_pose_where_is(m_scene, m_objArma); // XXX
|
2009-09-24 21:22:24 +00:00
|
|
|
// restore ourself
|
|
|
|
memcpy(m_objArma->obmat, m_obmat, sizeof(m_obmat));
|
|
|
|
// restore active targets
|
|
|
|
for (cit.begin(); !cit.end(); ++cit) {
|
|
|
|
(*cit)->RestoreTarget();
|
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
m_lastapplyframe = m_lastframe;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2008-09-17 01:29:54 +00:00
|
|
|
void BL_ArmatureObject::RestorePose()
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2008-09-17 01:29:54 +00:00
|
|
|
m_objArma->pose = m_armpose;
|
|
|
|
m_armpose = NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BL_ArmatureObject::SetPose(bPose *pose)
|
|
|
|
{
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
extract_pose_from_pose(m_pose, pose);
|
|
|
|
m_lastapplyframe = -1.0;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BL_ArmatureObject::SetActiveAction(BL_ActionActuator *act, short priority, double curtime)
|
|
|
|
{
|
2012-03-28 05:03:24 +00:00
|
|
|
if (curtime != m_lastframe) {
|
2002-10-12 11:37:38 +00:00
|
|
|
m_activePriority = 9999;
|
2009-09-24 21:22:24 +00:00
|
|
|
// compute the timestep for the underlying IK algorithm
|
|
|
|
m_timestep = curtime-m_lastframe;
|
2002-10-12 11:37:38 +00:00
|
|
|
m_lastframe= curtime;
|
|
|
|
m_activeAct = NULL;
|
2008-08-31 21:53:39 +00:00
|
|
|
// remember the pose at the start of the frame
|
2009-09-24 21:22:24 +00:00
|
|
|
GetPose(&m_framePose);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2009-09-24 21:22:24 +00:00
|
|
|
if (act)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2009-09-24 21:22:24 +00:00
|
|
|
if (priority<=m_activePriority)
|
|
|
|
{
|
|
|
|
if (priority<m_activePriority) {
|
|
|
|
// this action overwrites the previous ones, start from initial pose to cancel their effects
|
|
|
|
SetPose(m_framePose);
|
|
|
|
if (m_activeAct && (m_activeAct!=act))
|
|
|
|
/* Reset the blend timer since this new action cancels the old one */
|
2012-09-16 04:58:18 +00:00
|
|
|
m_activeAct->SetBlendTime(0.0);
|
2009-09-24 21:22:24 +00:00
|
|
|
}
|
|
|
|
m_activeAct = act;
|
|
|
|
m_activePriority = priority;
|
|
|
|
m_lastframe = curtime;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2012-06-06 22:38:39 +00:00
|
|
|
else {
|
2009-09-24 21:22:24 +00:00
|
|
|
act->SetBlendTime(0.0);
|
|
|
|
return false;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2009-09-24 21:22:24 +00:00
|
|
|
return false;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BL_ActionActuator * BL_ArmatureObject::GetActiveAction()
|
|
|
|
{
|
|
|
|
return m_activeAct;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BL_ArmatureObject::GetPose(bPose **pose)
|
|
|
|
{
|
|
|
|
/* If the caller supplies a null pose, create a new one. */
|
|
|
|
/* Otherwise, copy the armature's pose channels into the caller-supplied pose */
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
|
2006-04-28 17:35:03 +00:00
|
|
|
if (!*pose) {
|
2012-03-03 16:31:46 +00:00
|
|
|
/* probably not to good of an idea to
|
2012-03-04 04:35:12 +00:00
|
|
|
* duplicate everything, but it clears up
|
2012-03-03 16:31:46 +00:00
|
|
|
* a crash and memory leakage when
|
|
|
|
* &BL_ActionActuator::m_pose is freed
|
|
|
|
*/
|
2009-09-24 21:22:24 +00:00
|
|
|
game_copy_pose(pose, m_pose, 0);
|
2006-04-28 17:35:03 +00:00
|
|
|
}
|
2008-06-03 22:54:24 +00:00
|
|
|
else {
|
|
|
|
if (*pose == m_pose)
|
|
|
|
// no need to copy if the pointers are the same
|
|
|
|
return;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
extract_pose_from_pose(*pose, m_pose);
|
2008-06-03 22:54:24 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BL_ArmatureObject::GetMRDPose(bPose **pose)
|
|
|
|
{
|
|
|
|
/* If the caller supplies a null pose, create a new one. */
|
|
|
|
/* Otherwise, copy the armature's pose channels into the caller-supplied pose */
|
|
|
|
|
2008-09-17 01:29:54 +00:00
|
|
|
if (!*pose)
|
2009-09-24 21:22:24 +00:00
|
|
|
game_copy_pose(pose, m_pose, 0);
|
2008-09-17 01:29:54 +00:00
|
|
|
else
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
extract_pose_from_pose(*pose, m_pose);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
short BL_ArmatureObject::GetActivePriority()
|
|
|
|
{
|
|
|
|
return m_activePriority;
|
|
|
|
}
|
|
|
|
|
|
|
|
double BL_ArmatureObject::GetLastFrame()
|
|
|
|
{
|
|
|
|
return m_lastframe;
|
|
|
|
}
|
2005-04-23 11:36:44 +00:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
bool BL_ArmatureObject::GetBoneMatrix(Bone* bone, MT_Matrix4x4& matrix)
|
2005-04-23 11:36:44 +00:00
|
|
|
{
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
bPoseChannel *pchan;
|
|
|
|
|
|
|
|
ApplyPose();
|
2012-05-05 16:03:57 +00:00
|
|
|
pchan = BKE_pose_channel_find_name(m_objArma->pose, bone->name);
|
2012-03-24 07:52:14 +00:00
|
|
|
if (pchan)
|
2005-11-29 12:45:18 +00:00
|
|
|
matrix.setValue(&pchan->pose_mat[0][0]);
|
2008-09-17 01:29:54 +00:00
|
|
|
RestorePose();
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2008-09-17 01:29:54 +00:00
|
|
|
return (pchan != NULL);
|
2005-04-23 11:36:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
float BL_ArmatureObject::GetBoneLength(Bone* bone) const
|
|
|
|
{
|
2006-01-06 03:46:54 +00:00
|
|
|
return (float)(MT_Point3(bone->head) - MT_Point3(bone->tail)).length();
|
2005-04-23 11:36:44 +00:00
|
|
|
}
|
2009-09-24 21:22:24 +00:00
|
|
|
|
2010-10-31 04:11:39 +00:00
|
|
|
#ifdef WITH_PYTHON
|
2009-09-29 21:42:40 +00:00
|
|
|
|
2009-09-24 21:22:24 +00:00
|
|
|
// PYTHON
|
|
|
|
|
|
|
|
PyTypeObject BL_ArmatureObject::Type = {
|
|
|
|
PyVarObject_HEAD_INIT(NULL, 0)
|
|
|
|
"BL_ArmatureObject",
|
|
|
|
sizeof(PyObjectPlus_Proxy),
|
|
|
|
0,
|
|
|
|
py_base_dealloc,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
py_base_repr,
|
|
|
|
0,
|
|
|
|
&KX_GameObject::Sequence,
|
|
|
|
&KX_GameObject::Mapping,
|
|
|
|
0,0,0,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
|
|
|
|
0,0,0,0,0,0,0,
|
|
|
|
Methods,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
&KX_GameObject::Type,
|
|
|
|
0,0,0,0,0,0,
|
|
|
|
py_base_new
|
|
|
|
};
|
|
|
|
|
|
|
|
PyMethodDef BL_ArmatureObject::Methods[] = {
|
|
|
|
KX_PYMETHODTABLE_NOARGS(BL_ArmatureObject, update),
|
|
|
|
{NULL,NULL} //Sentinel
|
|
|
|
};
|
|
|
|
|
|
|
|
PyAttributeDef BL_ArmatureObject::Attributes[] = {
|
|
|
|
|
|
|
|
KX_PYATTRIBUTE_RO_FUNCTION("constraints", BL_ArmatureObject, pyattr_get_constraints),
|
|
|
|
KX_PYATTRIBUTE_RO_FUNCTION("channels", BL_ArmatureObject, pyattr_get_channels),
|
|
|
|
{NULL} //Sentinel
|
|
|
|
};
|
|
|
|
|
2012-09-16 04:58:18 +00:00
|
|
|
PyObject *BL_ArmatureObject::pyattr_get_constraints(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
2009-09-24 21:22:24 +00:00
|
|
|
{
|
|
|
|
return KX_PythonSeq_CreatePyObject((static_cast<BL_ArmatureObject*>(self_v))->m_proxy, KX_PYGENSEQ_OB_TYPE_CONSTRAINTS);
|
|
|
|
}
|
|
|
|
|
2012-09-16 04:58:18 +00:00
|
|
|
PyObject *BL_ArmatureObject::pyattr_get_channels(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
2009-09-24 21:22:24 +00:00
|
|
|
{
|
|
|
|
BL_ArmatureObject* self = static_cast<BL_ArmatureObject*>(self_v);
|
|
|
|
self->LoadChannels(); // make sure we have the channels
|
|
|
|
return KX_PythonSeq_CreatePyObject((static_cast<BL_ArmatureObject*>(self_v))->m_proxy, KX_PYGENSEQ_OB_TYPE_CHANNELS);
|
|
|
|
}
|
|
|
|
|
|
|
|
KX_PYMETHODDEF_DOC_NOARGS(BL_ArmatureObject, update,
|
|
|
|
"update()\n"
|
|
|
|
"Make sure that the armature will be updated on next graphic frame.\n"
|
|
|
|
"This is automatically done if a KX_ArmatureActuator with mode run is active\n"
|
2011-10-17 06:39:13 +00:00
|
|
|
"or if an action is playing. This function is useful in other cases.\n")
|
2009-09-24 21:22:24 +00:00
|
|
|
{
|
|
|
|
SetActiveAction(NULL, 0, KX_GetActiveEngine()->GetFrameTime());
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
}
|
2009-09-29 21:42:40 +00:00
|
|
|
|
2010-10-31 04:11:39 +00:00
|
|
|
#endif // WITH_PYTHON
|