Ejemplo n.º 1
0
LLVector3 LLViewerJointCollisionVolume::getVolumePos(LLVector3 &offset)
{
	mUpdateXform = TRUE;
	
	LLVector3 result = offset;
	result.scaleVec(getScale());
	result.rotVec(getWorldRotation());
	result += getWorldPosition();

	return result;
}
BOOL LLPolySkeletalDistortion::setInfo(LLPolySkeletalDistortionInfo *info)
{
        llassert(mInfo == NULL);
        if (info->mID < 0)
                return FALSE;
        mInfo = info;
        mID = info->mID;
        setWeight(getDefaultWeight(), FALSE );

        LLPolySkeletalDistortionInfo::bone_info_list_t::iterator iter;
        for (iter = getInfo()->mBoneInfoList.begin(); iter != getInfo()->mBoneInfoList.end(); iter++)
        {
                LLPolySkeletalBoneInfo *bone_info = &(*iter);
                LLJoint* joint = mAvatar->getJoint(bone_info->mBoneName);
                if (!joint)
                {
                        LL_WARNS() << "Joint " << bone_info->mBoneName << " not found." << LL_ENDL;
                        continue;
                }

                if (mJointScales.find(joint) != mJointScales.end())
                {
                        LL_WARNS() << "Scale deformation already supplied for joint " << joint->getName() << "." << LL_ENDL;
                }

                // store it
                mJointScales[joint] = bone_info->mScaleDeformation;

                // apply to children that need to inherit it
                for (LLJoint::child_list_t::iterator iter = joint->mChildren.begin();
                     iter != joint->mChildren.end(); ++iter)
                {
                        LLAvatarJoint* child_joint = (LLAvatarJoint*)(*iter);
                        if (child_joint->inheritScale())
                        {
                                LLVector3 childDeformation = LLVector3(child_joint->getScale());
                                childDeformation.scaleVec(bone_info->mScaleDeformation);
                                mJointScales[child_joint] = childDeformation;
                        }
                }

                if (bone_info->mHasPositionDeformation)
                {
                        if (mJointOffsets.find(joint) != mJointOffsets.end())
                        {
                                LL_WARNS() << "Offset deformation already supplied for joint " << joint->getName() << "." << LL_ENDL;
                        }
                        mJointOffsets[joint] = bone_info->mPositionDeformation;
                }
        }
        return TRUE;
}
Ejemplo n.º 3
0
BOOL LLVOTree::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, S32 face, BOOL pick_transparent, S32 *face_hitp,
									  LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal)
	
{

	if (!lineSegmentBoundingBox(start, end))
	{
		return FALSE;
	}

	const LLVector4a* exta = mDrawable->getSpatialExtents();

	//VECTORIZE THIS
	LLVector3 ext[2];
	ext[0].set(exta[0].getF32ptr());
	ext[1].set(exta[1].getF32ptr());
	
	LLVector3 center = (ext[1]+ext[0])*0.5f;
	LLVector3 size = (ext[1]-ext[0]);

	LLQuaternion quat = getRotation();

	center -= LLVector3(0,0,size.magVec() * 0.25f)*quat;

	size.scaleVec(LLVector3(0.25f, 0.25f, 1.f));
	size.mV[0] = llmin(size.mV[0], 1.f);
	size.mV[1] = llmin(size.mV[1], 1.f);

	LLVector3 pos, norm;
		
	if (linesegment_tetrahedron(start, end, center, size, quat, pos, norm))
	{
		if (intersection)
		{
			*intersection = pos;
		}

		if (normal)
		{
			*normal = norm;
		}
		return TRUE;
	}
	
	return FALSE;
}
Ejemplo n.º 4
0
	void xform_test_object_t::test<7>()	
	{
		LLXformMatrix formMatrix_obj;

		LLXformMatrix parent;
		LLVector3 llvecpos(1.0, 2.0, 3.0);
		LLVector3 llvecpospar(10.0, 20.0, 30.0);
		formMatrix_obj.setPosition(llvecpos);
		parent.setPosition(llvecpospar);

		LLVector3 llvecparentscale(1.0, 2.0, 0);
		parent.setScaleChildOffset(TRUE);
		parent.setScale(llvecparentscale);

		LLQuaternion quat(1, 2, 3, 4);
		LLQuaternion quatparent(5, 6, 7, 8);
		formMatrix_obj.setRotation(quat);
		parent.setRotation(quatparent);
		formMatrix_obj.setParent(&parent);

		parent.update();
		formMatrix_obj.update();

		LLVector3 worldPos = llvecpos;
		worldPos.scaleVec(llvecparentscale);
		worldPos *= quatparent;
		worldPos += llvecpospar;

		LLQuaternion worldRot = quat * quatparent; 

		ensure("getWorldPosition failed: ", formMatrix_obj.getWorldPosition() == worldPos);
		ensure("getWorldRotation failed: ", formMatrix_obj.getWorldRotation() == worldRot);

		ensure("getWorldPosition for parent failed: ", parent.getWorldPosition() == llvecpospar);
		ensure("getWorldRotation for parent failed: ", parent.getWorldRotation() == quatparent);
	}
Ejemplo n.º 5
0
LLVector3			LLVector3::scaledVec(const LLVector3& vec) const
{
	LLVector3 ret = LLVector3(*this);
	ret.scaleVec(vec);
	return ret;
}