[sldev] [VWR] VBO is broken
Nicholaz Beresford
nicholaz at blueflash.cc
Thu Oct 4 12:21:07 PDT 2007
Try the one attached.
Nick
Second Life from the inside out:
http://nicholaz-beresford.blogspot.com/
-------------- next part --------------
--- linden-orig/indra/llcharacter/llmotion.cpp 2007-09-13 15:35:18.000000000 +0200
+++ linden/indra/llcharacter/llmotion.cpp 2007-09-14 13:44:39.200250000 +0200
@@ -126,11 +126,6 @@
mDeactivateCallbackUserData = userdata;
}
-BOOL LLMotion::isBlending()
-{
- return mPose.getWeight() < 1.f;
-}
-
//-----------------------------------------------------------------------------
// activate()
//-----------------------------------------------------------------------------
@@ -147,16 +142,10 @@
void LLMotion::deactivate()
{
mActive = FALSE;
- mPose.setWeight(0.f);
if (mDeactivateCallback) (*mDeactivateCallback)(mDeactivateCallbackUserData);
onDeactivate();
}
-BOOL LLMotion::canDeprecate()
-{
- return TRUE;
-}
-
// End
--- linden-orig/indra/llcharacter/llmotion.h 2007-09-13 15:35:18.000000000 +0200
+++ linden/indra/llcharacter/llmotion.h 2007-09-14 13:44:40.794000000 +0200
@@ -99,14 +99,13 @@
void setStopped(BOOL stopped) { mStopped = stopped; }
- BOOL isBlending();
-
void activate();
void deactivate();
BOOL isActive() { return mActive; }
+
public:
//-------------------------------------------------------------------------
// animation callbacks to be implemented by subclasses
@@ -146,11 +145,6 @@
// called when a motion is deactivated
virtual void onDeactivate() = 0;
- // can we crossfade this motion with a new instance when restarted?
- // should ultimately always be TRUE, but lack of emote blending, etc
- // requires this
- virtual BOOL canDeprecate();
-
// optional callback routine called when animation deactivated.
void setDeactivateCallback( void (*cb)(void *), void* userdata );
--- linden-orig/indra/llcharacter/llmotioncontroller.cpp 2007-09-13 15:35:18.000000000 +0200
+++ linden/indra/llcharacter/llmotioncontroller.cpp 2007-09-14 13:44:42.122125000 +0200
@@ -194,44 +194,34 @@
//-----------------------------------------------------------------------------
void LLMotionController::addLoadedMotion(LLMotion* motionp)
{
- std::set<LLUUID> motions_to_kill;
-
- // gather all inactive, loaded motions
if (mLoadedMotions.size() > MAX_MOTION_INSTANCES)
{
// too many motions active this frame, kill all blenders
mPoseBlender.clearBlenders();
- for (motion_list_t::iterator loaded_motion_it = mLoadedMotions.begin();
- loaded_motion_it != mLoadedMotions.end();
- ++loaded_motion_it)
+ for (U32 i = 0; i < mLoadedMotions.size(); i++)
{
- LLMotion* cur_motionp = *loaded_motion_it;
+ LLMotion* cur_motionp = mLoadedMotions.front();
+ mLoadedMotions.pop_front();
// motion isn't playing, delete it
if (!isMotionActive(cur_motionp))
{
- motions_to_kill.insert(cur_motionp->getID());
+ mCharacter->requestStopMotion(cur_motionp);
+ mAllMotions.erase(cur_motionp->getID());
+ delete cur_motionp;
+ if (mLoadedMotions.size() <= MAX_MOTION_INSTANCES)
+ {
+ break;
+ }
+ }
+ else
+ {
+ // put active motion on back
+ mLoadedMotions.push_back(cur_motionp);
}
}
}
-
- // clean up all inactive, loaded motions
- for (std::set<LLUUID>::iterator motion_it = motions_to_kill.begin();
- motion_it != motions_to_kill.end();
- ++motion_it)
- {
- // look up the motion again by ID to get canonical instance
- // and kill it only if that one is inactive
- LLUUID motion_id = *motion_it;
- LLMotion* motionp = findMotion(motion_id);
- if (motionp && !isMotionActive(motionp))
- {
- removeMotion(motion_id);
- }
- }
-
- // add new motion to loaded list
mLoadedMotions.push_back(motionp);
}
@@ -290,24 +280,14 @@
void LLMotionController::removeMotion( const LLUUID& id)
{
LLMotion* motionp = findMotion(id);
-
- removeMotionInstance(motionp);
-
- mAllMotions.erase(id);
-}
-
-// removes instance of a motion from all runtime structures, but does
-// not erase entry by ID, as this could be a duplicate instance
-// use removeMotion(id) to remove all references to a given motion by id.
-void LLMotionController::removeMotionInstance(LLMotion* motionp)
-{
if (motionp)
{
- stopMotionInstance(motionp, TRUE);
+ stopMotionLocally(id, TRUE);
mLoadingMotions.erase(motionp);
mLoadedMotions.remove(motionp);
mActiveMotions.remove(motionp);
+ mAllMotions.erase(id);
delete motionp;
}
}
@@ -368,39 +348,28 @@
//-----------------------------------------------------------------------------
BOOL LLMotionController::startMotion(const LLUUID &id, F32 start_offset)
{
- // do we have an instance of this motion for this character?
- LLMotion *motion = findMotion(id);
-
- // motion that is stopping will be allowed to stop but
- // replaced by a new instance of that motion
- if (motion
- && motion->canDeprecate()
- && motion->getFadeWeight() > 0.01f // not LOD-ed out
- && (motion->isBlending() || motion->getStopTime() != 0.f))
- {
- deprecateMotionInstance(motion);
- // force creation of new instance
- motion = NULL;
- }
-
- // create new motion instance
- if (!motion)
- {
- motion = createMotion(id);
- }
+ // look for motion in our list of created motions
+ LLMotion *motion = createMotion(id);
if (!motion)
{
return FALSE;
}
- //if the motion is already active and allows deprecation, then let it keep playing
- else if (motion->canDeprecate() && isMotionActive(motion))
+ //if the motion is already active, then we're done
+ else if (isMotionActive(motion)) // motion is playing and...
{
- return TRUE;
+ if (motion->isStopped()) // motion has been stopped
+ {
+ deactivateMotion(motion, false);
+ }
+ else if (mTime < motion->mSendStopTimestamp) // motion is still active
+ {
+ return TRUE;
+ }
}
// llinfos << "Starting motion " << name << llendl;
- return activateMotionInstance(motion, mTime - start_offset);
+ return activateMotion(motion, mTime - start_offset);
}
@@ -411,12 +380,6 @@
{
// if already inactive, return false
LLMotion *motion = findMotion(id);
-
- return stopMotionInstance(motion, stop_immediate);
-}
-
-BOOL LLMotionController::stopMotionInstance(LLMotion* motion, BOOL stop_immediate)
-{
if (!motion)
{
return FALSE;
@@ -433,7 +396,7 @@
if (stop_immediate)
{
- deactivateMotionInstance(motion);
+ deactivateMotion(motion, false);
}
return TRUE;
}
@@ -529,7 +492,7 @@
{
if (motionp->isStopped() && mTime > motionp->getStopTime() + motionp->getEaseOutDuration())
{
- deactivateMotionInstance(motionp);
+ deactivateMotion(motionp, false);
}
else if (motionp->isStopped() && mTime > motionp->getStopTime())
{
@@ -547,7 +510,7 @@
if (mLastTime <= motionp->mSendStopTimestamp)
{
mCharacter->requestStopMotion( motionp );
- stopMotionInstance(motionp, FALSE);
+ stopMotionLocally(motionp->getID(), FALSE);
}
}
else if (mTime >= motionp->mActivationTimestamp)
@@ -575,7 +538,7 @@
if (mLastTime <= motionp->mSendStopTimestamp)
{
mCharacter->requestStopMotion( motionp );
- stopMotionInstance(motionp, FALSE);
+ stopMotionLocally(motionp->getID(), FALSE);
}
}
@@ -583,8 +546,7 @@
{
if (motionp->isStopped() && mTime > motionp->getStopTime() + motionp->getEaseOutDuration())
{
- posep->setWeight(0.f);
- deactivateMotionInstance(motionp);
+ deactivateMotion(motionp, true);
}
continue;
}
@@ -610,8 +572,7 @@
}
else
{
- posep->setWeight(0.f);
- deactivateMotionInstance(motionp);
+ deactivateMotion(motionp, true);
continue;
}
}
@@ -656,7 +617,7 @@
if (mLastTime <= motionp->mSendStopTimestamp)
{
mCharacter->requestStopMotion( motionp );
- stopMotionInstance(motionp, FALSE);
+ stopMotionLocally(motionp->getID(), FALSE);
}
}
@@ -700,7 +661,7 @@
// propagate this to the network
// as not all viewers are guaranteed to have access to the same logic
mCharacter->requestStopMotion( motionp );
- stopMotionInstance(motionp, FALSE);
+ stopMotionLocally(motionp->getID(), FALSE);
}
}
@@ -772,7 +733,7 @@
// this motion should be playing
if (!motionp->isStopped())
{
- activateMotionInstance(motionp, mTime);
+ activateMotion(motionp, mTime);
}
}
else if (status == LLMotion::STATUS_FAILURE)
@@ -780,7 +741,6 @@
llinfos << "Motion " << motionp->getID() << " init failed." << llendl;
sRegistry.markBad(motionp->getID());
mLoadingMotions.erase(curiter);
-
mAllMotions.erase(motionp->getID());
delete motionp;
}
@@ -813,9 +773,9 @@
//-----------------------------------------------------------------------------
-// activateMotionInstance()
+// activateMotion()
//-----------------------------------------------------------------------------
-BOOL LLMotionController::activateMotionInstance(LLMotion *motion, F32 time)
+BOOL LLMotionController::activateMotion(LLMotion *motion, F32 time)
{
if (mLoadingMotions.find(motion) != mLoadingMotions.end())
{
@@ -858,38 +818,23 @@
}
//-----------------------------------------------------------------------------
-// deactivateMotionInstance()
+// deactivateMotion()
//-----------------------------------------------------------------------------
-BOOL LLMotionController::deactivateMotionInstance(LLMotion *motion)
+BOOL LLMotionController::deactivateMotion(LLMotion *motion, bool remove_weight)
{
- motion->deactivate();
-
- motion_set_t::iterator found_it = mDeprecatedMotions.find(motion);
- if (found_it != mDeprecatedMotions.end())
- {
- // deprecated motions need to be completely excised
- removeMotionInstance(motion);
- mDeprecatedMotions.erase(found_it);
- }
- else
+ if( remove_weight )
{
- // for motions that we are keeping, simply remove from active queue
- mActiveMotions.remove(motion);
+ // immediately remove pose weighting instead of letting it time out
+ LLPose *posep = motion->getPose();
+ posep->setWeight(0.f);
}
+
+ motion->deactivate();
+ mActiveMotions.remove(motion);
return TRUE;
}
-void LLMotionController::deprecateMotionInstance(LLMotion* motion)
-{
- mDeprecatedMotions.insert(motion);
-
- //fade out deprecated motion
- stopMotionInstance(motion, FALSE);
- //no longer canonical
- mAllMotions.erase(motion->getID());
-}
-
//-----------------------------------------------------------------------------
// isMotionActive()
//-----------------------------------------------------------------------------
@@ -912,7 +857,7 @@
//-----------------------------------------------------------------------------
LLMotion *LLMotionController::findMotion(const LLUUID& id)
{
- return get_if_there<LLUUID, LLMotion*>(mAllMotions, id, NULL);
+ return mAllMotions[id];
}
//-----------------------------------------------------------------------------
--- linden-orig/indra/llcharacter/llmotioncontroller.h 2007-09-13 15:35:18.000000000 +0200
+++ linden/indra/llcharacter/llmotioncontroller.h 2007-09-14 13:44:42.840875000 +0200
@@ -179,21 +179,16 @@
LLMotion *findMotion( const LLUUID& id );
protected:
- // internal operations act on motion instances directly
- // as there can be duplicate motions per id during blending overlap
void deleteAllMotions();
void addLoadedMotion(LLMotion *motion);
- BOOL activateMotionInstance(LLMotion *motion, F32 time);
- BOOL deactivateMotionInstance(LLMotion *motion);
- void deprecateMotionInstance(LLMotion* motion);
- BOOL stopMotionInstance(LLMotion *motion, BOOL stop_imemdiate);
- void removeMotionInstance(LLMotion* motion);
+ BOOL activateMotion(LLMotion *motion, F32 time);
+ BOOL deactivateMotion(LLMotion *motion, bool remove_weight);
void updateRegularMotions();
void updateAdditiveMotions();
void resetJointSignatures();
void updateMotionsByType(LLMotion::LLMotionBlendType motion_type);
-
protected:
+
F32 mTimeFactor;
static LLMotionRegistry sRegistry;
LLPoseBlender mPoseBlender;
@@ -208,13 +203,11 @@
// Once an animations is loaded, it will be initialized and put on the mLoadedMotions deque.
// Any animation that is currently playing also sits in the mActiveMotions list.
- typedef std::map<LLUUID, LLMotion*> motion_map_t;
- motion_map_t mAllMotions;
+ std::map<LLUUID, LLMotion*> mAllMotions;
motion_set_t mLoadingMotions;
motion_list_t mLoadedMotions;
motion_list_t mActiveMotions;
- motion_set_t mDeprecatedMotions;
LLFrameTimer mTimer;
F32 mTime;
--- linden-orig/indra/llcharacter/llpose.cpp 2007-09-13 15:35:18.000000000 +0200
+++ linden/indra/llcharacter/llpose.cpp 2007-09-14 13:44:44.153375000 +0200
@@ -275,9 +275,9 @@
joint_state_index < JSB_NUM_JOINT_STATES && mJointStates[joint_state_index] != NULL;
joint_state_index++)
{
+ U32 current_usage = mJointStates[joint_state_index]->getUsage();
+ F32 current_weight = mJointStates[joint_state_index]->getWeight();
LLJointState* jsp = mJointStates[joint_state_index];
- U32 current_usage = jsp->getUsage();
- F32 current_weight = jsp->getWeight();
if (current_weight == 0.f)
{
@@ -292,14 +292,17 @@
// add in pos for this jointstate modulated by weight
added_pos += jsp->getPosition() * (new_weight_sum - sum_weights[POS_WEIGHT]);
+ //sum_weights[POS_WEIGHT] = new_weight_sum;
}
+ // now do scale
if(current_usage & LLJointState::SCALE)
{
F32 new_weight_sum = llmin(1.f, current_weight + sum_weights[SCALE_WEIGHT]);
// add in scale for this jointstate modulated by weight
added_scale += jsp->getScale() * (new_weight_sum - sum_weights[SCALE_WEIGHT]);
+ //sum_weights[SCALE_WEIGHT] = new_weight_sum;
}
if (current_usage & LLJointState::ROT)
@@ -308,6 +311,7 @@
// add in rotation for this jointstate modulated by weight
added_rot = nlerp((new_weight_sum - sum_weights[ROT_WEIGHT]), added_rot, jsp->getRotation()) * added_rot;
+ //sum_weights[ROT_WEIGHT] = new_weight_sum;
}
}
else
@@ -322,13 +326,13 @@
F32 new_weight_sum = llmin(1.f, current_weight + sum_weights[POS_WEIGHT]);
// blend positions from both
- blended_pos = lerp(jsp->getPosition(), blended_pos, sum_weights[POS_WEIGHT] / new_weight_sum);
+ blended_pos = lerp(mJointStates[joint_state_index]->getPosition(), blended_pos, sum_weights[POS_WEIGHT] / new_weight_sum);
sum_weights[POS_WEIGHT] = new_weight_sum;
}
else
{
// copy position from current
- blended_pos = jsp->getPosition();
+ blended_pos = mJointStates[joint_state_index]->getPosition();
sum_weights[POS_WEIGHT] = current_weight;
}
}
@@ -341,13 +345,13 @@
F32 new_weight_sum = llmin(1.f, current_weight + sum_weights[SCALE_WEIGHT]);
// blend scales from both
- blended_scale = lerp(jsp->getScale(), blended_scale, sum_weights[SCALE_WEIGHT] / new_weight_sum);
+ blended_scale = lerp(mJointStates[joint_state_index]->getScale(), blended_scale, sum_weights[SCALE_WEIGHT] / new_weight_sum);
sum_weights[SCALE_WEIGHT] = new_weight_sum;
}
else
{
// copy scale from current
- blended_scale = jsp->getScale();
+ blended_scale = mJointStates[joint_state_index]->getScale();
sum_weights[SCALE_WEIGHT] = current_weight;
}
}
@@ -360,13 +364,13 @@
F32 new_weight_sum = llmin(1.f, current_weight + sum_weights[ROT_WEIGHT]);
// blend rotations from both
- blended_rot = nlerp(sum_weights[ROT_WEIGHT] / new_weight_sum, jsp->getRotation(), blended_rot);
+ blended_rot = nlerp(sum_weights[ROT_WEIGHT] / new_weight_sum, mJointStates[joint_state_index]->getRotation(), blended_rot);
sum_weights[ROT_WEIGHT] = new_weight_sum;
}
else
{
// copy rotation from current
- blended_rot = jsp->getRotation();
+ blended_rot = mJointStates[joint_state_index]->getRotation();
sum_weights[ROT_WEIGHT] = current_weight;
}
}
--- linden-orig/indra/llcharacter/llpose.h 2007-09-13 15:35:18.000000000 +0200
+++ linden/indra/llcharacter/llpose.h 2007-09-14 13:44:44.856500000 +0200
@@ -81,7 +81,7 @@
S32 getNumJointStates() const;
};
-const S32 JSB_NUM_JOINT_STATES = 6;
+const S32 JSB_NUM_JOINT_STATES = 4;
class LLJointStateBlender
{
More information about the SLDev
mailing list