void object::test<2>() { // // test the non-default constructor // LLBBox bbox2(LLVector3(1.0f, 2.0f, 3.0f), LLQuaternion(), LLVector3(2.0f, 3.0f, 4.0f), LLVector3(4.0f, 5.0f, 6.0f)); ensure_equals("Custom bbox min", bbox2.getMinLocal(), LLVector3(2.0f, 3.0f, 4.0f)); ensure_equals("Custom bbox max", bbox2.getMaxLocal(), LLVector3(4.0f, 5.0f, 6.0f)); ensure_equals("Custom bbox pos agent", bbox2.getPositionAgent(), LLVector3(1.0f, 2.0f, 3.0f)); ensure_equals("Custom bbox rotation", bbox2.getRotation(), LLQuaternion(0.0f, 0.0f, 0.0f, 1.0f)); }
// the selection bbox isn't axis aligned, so we must construct one // should this be cached in the selection manager? yes. LLBBox get_selection_axis_aligned_bbox() { LLBBox selection_bbox = LLSelectMgr::getInstance()->getBBoxOfSelection(); LLVector3 position = selection_bbox.getPositionAgent(); LLBBox axis_aligned_bbox = LLBBox(position, LLQuaternion(), LLVector3(), LLVector3()); axis_aligned_bbox.addPointLocal(LLVector3()); // cycle over the nodes in selection for (LLObjectSelection::iterator selection_iter = LLSelectMgr::getInstance()->getSelection()->begin(); selection_iter != LLSelectMgr::getInstance()->getSelection()->end(); ++selection_iter) { LLSelectNode *select_node = *selection_iter; if (select_node) { LLViewerObject* object = select_node->getObject(); if (object) { axis_aligned_bbox.addBBoxAgent(object->getBoundingBoxAgent()); } } } return axis_aligned_bbox; }
LLCamera LLSpatialBridge::transformCamera(LLCamera& camera) { LLCamera ret = camera; LLXformMatrix* mat = mDrawable->getXform(); LLVector3 center = LLVector3(0,0,0) * mat->getWorldMatrix(); LLQuaternion rotation = LLQuaternion(mat->getWorldMatrix()); LLVector3 delta = ret.getOrigin() - center; LLQuaternion rot = ~mat->getRotation(); delta *= rot; LLVector3 lookAt = ret.getAtAxis(); LLVector3 up_axis = ret.getUpAxis(); LLVector3 left_axis = ret.getLeftAxis(); lookAt *= rot; up_axis *= rot; left_axis *= rot; if (!delta.isFinite()) { delta.clearVec(); } ret.setOrigin(delta); ret.setAxes(lookAt, left_axis, up_axis); return ret; }
LLVector3 primbackup::offset_agent(LLVector3 offset) { LLVector3 pos= gAgent.getPositionAgent(); LLQuaternion agent_rot=LLQuaternion(gAgent.getAtAxis(),gAgent.getLeftAxis(),gAgent.getUpAxis()); pos=(offset*agent_rot+pos); return pos; }
void object::test<12>() { // // test the expand() method // LLBBox bbox1; bbox1.expand(0.0); ensure_equals("Zero-expanded Default BBox center", bbox1.getCenterLocal(), LLVector3(0.0f, 0.0f, 0.0f)); LLBBox bbox2(LLVector3(1.0f, 1.0f, 1.0f), LLQuaternion(), LLVector3(1.0f, 1.0f, 1.0f), LLVector3(3.0f, 3.0f, 3.0f)); bbox2.expand(0.0); ensure_equals("Zero-expanded center local", bbox2.getCenterLocal(), LLVector3(2.0f, 2.0f, 2.0f)); ensure_equals("Zero-expanded center agent", bbox2.getCenterAgent(), LLVector3(3.0f, 3.0f, 3.0f)); ensure_equals("Zero-expanded min", bbox2.getMinLocal(), LLVector3(1.0f, 1.0f, 1.0f)); ensure_equals("Zero-expanded max", bbox2.getMaxLocal(), LLVector3(3.0f, 3.0f, 3.0f)); bbox2.expand(0.5); ensure_equals("Positive-expanded center", bbox2.getCenterLocal(), LLVector3(2.0f, 2.0f, 2.0f)); ensure_equals("Positive-expanded min", bbox2.getMinLocal(), LLVector3(0.5f, 0.5f, 0.5f)); ensure_equals("Positive-expanded max", bbox2.getMaxLocal(), LLVector3(3.5f, 3.5f, 3.5f)); bbox2.expand(-1.0); ensure_equals("Negative-expanded center", bbox2.getCenterLocal(), LLVector3(2.0f, 2.0f, 2.0f)); ensure_equals("Negative-expanded min", bbox2.getMinLocal(), LLVector3(1.5f, 1.5f, 1.5f)); ensure_equals("Negative-expanded max", bbox2.getMaxLocal(), LLVector3(2.5f, 2.5f, 2.5f)); }
void object::test<13>() { // // test the localToAgent() method // LLBBox bbox1(LLVector3(1.0f, 1.0f, 1.0f), LLQuaternion(), LLVector3(1.0f, 1.0f, 1.0f), LLVector3(3.0f, 3.0f, 3.0f)); ensure_equals("localToAgent(1,2,3)", bbox1.localToAgent(LLVector3(1.0f, 2.0f, 3.0f)), LLVector3(2.0f, 3.0f, 4.0f)); LLBBox bbox2(LLVector3(1.0f, 1.0f, 1.0f), LLQuaternion(ANGLE, LLVector3(1.0f, 0.0f, 0.0f)), LLVector3(1.0f, 1.0f, 1.0f), LLVector3(3.0f, 3.0f, 3.0f)); ensure("localToAgent(1,2,3) rot", APPROX_EQUAL(bbox2.localToAgent(LLVector3(1.0f, 2.0f, 3.0f)), LLVector3(2.0f, -2.0f, 3.0f))); }
const LLVector3& LLVector3::rotVec(F32 angle, const LLVector3 &vec) { if ( !vec.isExactlyZero() && angle ) { *this = *this * LLQuaternion(angle, vec); } return *this; }
void LLSpatialBridge::updateSpatialExtents() { LLSpatialGroup* root = (LLSpatialGroup*) mOctree->getListener(0); { LLFastTimer ftm(LLFastTimer::FTM_CULL_REBOUND); root->rebound(); } LLXformMatrix* mat = mDrawable->getXform(); LLVector3 offset = root->mBounds[0]; LLVector3 size = root->mBounds[1]; LLVector3 center = LLVector3(0,0,0) * mat->getWorldMatrix(); LLQuaternion rotation = LLQuaternion(mat->getWorldMatrix()); offset *= rotation; center += offset; LLVector3 v[4]; //get 4 corners of bounding box v[0] = (size * rotation); v[1] = (LLVector3(-size.mV[0], -size.mV[1], size.mV[2]) * rotation); v[2] = (LLVector3(size.mV[0], -size.mV[1], -size.mV[2]) * rotation); v[3] = (LLVector3(-size.mV[0], size.mV[1], -size.mV[2]) * rotation); LLVector3& newMin = mExtents[0]; LLVector3& newMax = mExtents[1]; newMin = newMax = center; for (U32 i = 0; i < 4; i++) { for (U32 j = 0; j < 3; j++) { F32 delta = fabsf(v[i].mV[j]); F32 min = center.mV[j] - delta; F32 max = center.mV[j] + delta; if (min < newMin.mV[j]) { newMin.mV[j] = min; } if (max > newMax.mV[j]) { newMax.mV[j] = max; } } } LLVector3 diagonal = newMax - newMin; mRadius = diagonal.magVec() * 0.5f; mPositionGroup.setVec((newMin + newMax) * 0.5f); updateBinRadius(); }
void object::test<7>() { // // test the getExtentLocal() method // ensure_equals("Default bbox local extent", LLBBox().getExtentLocal(), LLVector3(0.0f, 0.0f, 0.0f)); LLBBox bbox1(LLVector3(1.0f, 2.0f, 3.0f), LLQuaternion(), LLVector3(2.0f, 4.0f, 6.0f), LLVector3(4.0f, 6.0f, 8.0f)); ensure_equals("Custom bbox extent local", bbox1.getExtentLocal(), LLVector3(2.0f, 2.0f, 2.0f)); LLBBox bbox2(LLVector3(1.0f, 1.0f, 1.0f), LLQuaternion(ANGLE, LLVector3(0.0f, 0.0f, 1.0f)), LLVector3(2.0f, 2.0f, 2.0f), LLVector3(4.0f, 4.0f, 4.0f)); ensure_equals("Custom bbox extent local with rot", bbox1.getExtentLocal(), LLVector3(2.0f, 2.0f, 2.0f)); }
void object::test<6>() { // // test the getCenterAgent() // ensure_equals("Default bbox agent center", LLBBox().getCenterAgent(), LLVector3(0.0f, 0.0f, 0.0f)); LLBBox bbox1(LLVector3(1.0f, 2.0f, 3.0f), LLQuaternion(), LLVector3(2.0f, 4.0f, 6.0f), LLVector3(4.0f, 6.0f, 8.0f)); ensure_equals("Custom bbox center agent", bbox1.getCenterAgent(), LLVector3(4.0f, 7.0f, 10.0f)); LLBBox bbox2(LLVector3(1.0f, 1.0f, 1.0f), LLQuaternion(ANGLE, LLVector3(0.0f, 0.0f, 1.0f)), LLVector3(2.0f, 2.0f, 2.0f), LLVector3(4.0f, 4.0f, 4.0f)); ensure("Custom bbox center agent with rot", APPROX_EQUAL(bbox2.getCenterAgent(), LLVector3(-2.0f, 4.0f, 4.0f))); }
void object::test<5>() { // // test the getCenterLocal() method // ensure_equals("Default bbox local center", LLBBox().getCenterLocal(), LLVector3(0.0f, 0.0f, 0.0f)); LLBBox bbox1(LLVector3(1.0f, 2.0f, 3.0f), LLQuaternion(), LLVector3(2.0f, 4.0f, 6.0f), LLVector3(4.0f, 6.0f, 8.0f)); ensure_equals("Custom bbox center local", bbox1.getCenterLocal(), LLVector3(3.0f, 5.0f, 7.0f)); LLBBox bbox2(LLVector3(1.0f, 1.0f, 1.0f), LLQuaternion(ANGLE, LLVector3(0.0f, 0.0f, 1.0f)), LLVector3(2.0f, 2.0f, 2.0f), LLVector3(4.0f, 4.0f, 4.0f)); ensure_equals("Custom bbox center local with rot", bbox2.getCenterLocal(), LLVector3(3.0f, 3.0f, 3.0f)); }
LLMatrix4::LLMatrix4(const F32 angle, const LLVector4 &vec) { initRotation(LLQuaternion(angle, vec)); mMatrix[3][0] = 0.f; mMatrix[3][1] = 0.f; mMatrix[3][2] = 0.f; mMatrix[3][3] = 1.f; }
void LLSDMessageReaderTestObject::test<17>() // Quaternion { LLQuaternion outValue, inValue = LLQuaternion(1,2,3,4); LLSD sdValue = ll_sd_from_quaternion(inValue); LLSDMessageReader msg = testType(sdValue); msg.getQuat("block", "var", outValue); ensure_equals("Ensure Quaternion", outValue, inValue); }
const LLVector3& LLVector3::rotVec(F32 angle, F32 x, F32 y, F32 z) { LLVector3 vec(x, y, z); if ( !vec.isExactlyZero() && angle ) { *this = *this * LLQuaternion(angle, vec); } return *this; }
void LLWLParamManager::update(LLViewerCamera * cam) { LLFastTimer ftm(LLFastTimer::FTM_UPDATE_WLPARAM); // update clouds, sun, and general mCurParams.updateCloudScrolling(); // update only if running if(mAnimator.mIsRunning) { mAnimator.update(mCurParams); } // update the shaders and the menu propagateParameters(); // sync menus if they exist if(LLFloaterWindLight::isOpen()) { LLFloaterWindLight::instance()->syncMenu(); } if(LLFloaterDayCycle::isOpen()) { LLFloaterDayCycle::instance()->syncMenu(); } if(LLFloaterEnvSettings::isOpen()) { LLFloaterEnvSettings::instance()->syncMenu(); } F32 camYaw = cam->getYaw(); stop_glerror(); // *TODO: potential optimization - this block may only need to be // executed some of the time. For example for water shaders only. { F32 camYawDelta = mSunDeltaYaw * DEG_TO_RAD; LLVector3 lightNorm3(mLightDir); lightNorm3 *= LLQuaternion(-(camYaw + camYawDelta), LLVector3(0.f, 1.f, 0.f)); mRotatedLightDir = LLVector4(lightNorm3, 0.f); LLViewerShaderMgr::shader_iter shaders_iter, end_shaders; end_shaders = LLViewerShaderMgr::instance()->endShaders(); for(shaders_iter = LLViewerShaderMgr::instance()->beginShaders(); shaders_iter != end_shaders; ++shaders_iter) { if (shaders_iter->mProgramObject != 0 && (gPipeline.canUseWindLightShaders() || shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER)) { shaders_iter->mUniformsDirty = TRUE; } } } }
LLMatrix4::LLMatrix4(const F32 roll, const F32 pitch, const F32 yaw) { LLMatrix3 mat(roll, pitch, yaw); initRotation(LLQuaternion(mat)); mMatrix[3][0] = 0.f; mMatrix[3][1] = 0.f; mMatrix[3][2] = 0.f; mMatrix[3][3] = 1.f; }
void LLSDMessageBuilderTestObject::test<14>() // Quaternion { LLQuaternion outValue, inValue = LLQuaternion(1,2,3,4); LLSDMessageBuilder builder = defaultBuilder(); builder.addQuat("var", inValue); LLSDMessageReader reader = setReader(builder); reader.getQuat("block", "var", outValue); ensure_equals("Ensure Quaternion", inValue, outValue); }
bool dxcmd(std::string revised_text, EChatType type) { std::istringstream i(revised_text); std::string command; i >> command; LLStringUtil::toLower(command); if(command != "") { if(command == "###test") { llinfos << "test chat dxchatcmd!" << llendl; return false; } else if(command == "###platform") { llinfos << "rez a platform!" << llendl; LLVector3 agentPos = gAgent.getPositionAgent()+(gAgent.getVelocity()*(F32)0.333); LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_ObjectAdd); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->addUUIDFast(_PREHASH_GroupID, gAgent.getGroupID()); msg->nextBlockFast(_PREHASH_ObjectData); msg->addU8Fast(_PREHASH_PCode, LL_PCODE_VOLUME); msg->addU8Fast(_PREHASH_Material, LL_MCODE_METAL); if(agentPos.mV[2] > 4096.0)msg->addU32Fast(_PREHASH_AddFlags, FLAGS_CREATE_SELECTED); else msg->addU32Fast(_PREHASH_AddFlags, 0); LLVolumeParams volume_params; volume_params.setType( LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE ); volume_params.setBeginAndEndS( 0.f, 1.f ); volume_params.setBeginAndEndT( 0.f, 1.f ); volume_params.setRatio ( 1, 1 ); volume_params.setShear ( 0, 0 ); LLVolumeMessage::packVolumeParams(&volume_params, msg); LLVector3 rezpos = agentPos - LLVector3(0.0f,0.0f,2.5f); msg->addVector3Fast(_PREHASH_Scale, LLVector3(20.0f,20.0f,0.25f) ); msg->addQuatFast(_PREHASH_Rotation, LLQuaternion() ); msg->addVector3Fast(_PREHASH_RayStart, rezpos ); msg->addVector3Fast(_PREHASH_RayEnd, rezpos ); msg->addU8Fast(_PREHASH_BypassRaycast, (U8)1 ); msg->addU8Fast(_PREHASH_RayEndIsIntersection, (U8)FALSE ); msg->addU8Fast(_PREHASH_State, 0); msg->addUUIDFast(_PREHASH_RayTargetID, LLUUID::null ); msg->sendReliable(gAgent.getRegionHost()); return false; } } return true; }
void object::test<14>() { // // test the agentToLocal() method // LLBBox bbox1(LLVector3(1.0f, 1.0f, 1.0f), LLQuaternion(), LLVector3(1.0f, 1.0f, 1.0f), LLVector3(3.0f, 3.0f, 3.0f)); ensure_equals("agentToLocal(1,2,3)", bbox1.agentToLocal(LLVector3(1.0f, 2.0f, 3.0f)), LLVector3(0.0f, 1.0f, 2.0f)); ensure_equals("agentToLocal(localToAgent)", bbox1.agentToLocal(bbox1.localToAgent(LLVector3(1.0f, 2.0f, 3.0f))), LLVector3(1.0f, 2.0f, 3.0f)); LLBBox bbox2(LLVector3(1.0f, 1.0f, 1.0f), LLQuaternion(ANGLE, LLVector3(1.0f, 0.0f, 0.0f)), LLVector3(1.0f, 1.0f, 1.0f), LLVector3(3.0f, 3.0f, 3.0f)); ensure("agentToLocal(1,2,3) rot", APPROX_EQUAL(bbox2.agentToLocal(LLVector3(1.0f, 2.0f, 3.0f)), LLVector3(0.0f, 2.0f, -1.0f))); ensure("agentToLocal(localToAgent) rot", APPROX_EQUAL(bbox2.agentToLocal(bbox2.localToAgent(LLVector3(1.0f, 2.0f, 3.0f))), LLVector3(1.0f, 2.0f, 3.0f))); }
void object::test<11>() { // // test the addBBoxAgent() method // LLBBox bbox1(LLVector3(1.0f, 1.0f, 1.0f), LLQuaternion(1.0, 0.0, 0.0, 1.0), LLVector3(2.0f, 2.0f, 2.0f), LLVector3(4.0f, 4.0f, 4.0f)); bbox1.addPointAgent(LLVector3(1.0f, 1.0f, 1.0f)); bbox1.addPointAgent(LLVector3(3.0f, 3.0f, 3.0f)); bbox1.addBBoxLocal(LLBBox(LLVector3(1.0f, 1.0f, 1.0f), LLQuaternion(), LLVector3(5.0f, 5.0f, 5.0f), LLVector3(10.0f, 10.0f, 10.0f))); ensure_equals("addPointAgent center local (2)", bbox1.getCenterLocal(), LLVector3(5.0f, 5.0f, 3.0f)); ensure_equals("addPointAgent center agent (2)", bbox1.getCenterAgent(), LLVector3(6.0f, -10.0f, 8.0f)); ensure_equals("addPointAgent min (2)", bbox1.getMinLocal(), LLVector3(0.0f, 0.0f, -4.0f)); ensure_equals("addPointAgent max (2)", bbox1.getMaxLocal(), LLVector3(10.0f, 10.0f, 10.0f)); }
LLBBox LLBBox::getAxisAligned() const { // no rotation = axis aligned rotation LLBBox aligned(mPosAgent, LLQuaternion(), LLVector3(), LLVector3()); // add the center point so that it's not empty aligned.addPointAgent(mPosAgent); // add our BBox aligned.addBBoxAgent(*this); return aligned; }
void object::test<1>() { // // test the default constructor // LLBBox bbox1; ensure_equals("Default bbox min", bbox1.getMinLocal(), LLVector3(0.0f, 0.0f, 0.0f)); ensure_equals("Default bbox max", bbox1.getMaxLocal(), LLVector3(0.0f, 0.0f, 0.0f)); ensure_equals("Default bbox pos agent", bbox1.getPositionAgent(), LLVector3(0.0f, 0.0f, 0.0f)); ensure_equals("Default bbox rotation", bbox1.getRotation(), LLQuaternion(0.0f, 0.0f, 0.0f, 1.0f)); }
void object::test<9>() { // // test the addBBoxLocal() method // LLBBox bbox1; bbox1.addBBoxLocal(LLBBox(LLVector3(), LLQuaternion(), LLVector3(0.0f, 0.0f, 0.0f), LLVector3(3.0f, 3.0f, 3.0f))); ensure_equals("addPointLocal center local (3)", bbox1.getCenterLocal(), LLVector3(1.5f, 1.5f, 1.5f)); ensure_equals("addPointLocal min (3)", bbox1.getMinLocal(), LLVector3(0.0f, 0.0f, 0.0f)); ensure_equals("addPointLocal max (3)", bbox1.getMaxLocal(), LLVector3(3.0f, 3.0f, 3.0f)); bbox1.addBBoxLocal(LLBBox(LLVector3(1.0f, 1.0f, 1.0f), LLQuaternion(), LLVector3(5.0f, 5.0f, 5.0f), LLVector3(10.0f, 10.0f, 10.0f))); ensure_equals("addPointLocal center local (4)", bbox1.getCenterLocal(), LLVector3(5.0f, 5.0f, 5.0f)); ensure_equals("addPointLocal center agent (4)", bbox1.getCenterAgent(), LLVector3(5.0f, 5.0f, 5.0f)); ensure_equals("addPointLocal min (4)", bbox1.getMinLocal(), LLVector3(0.0f, 0.0f, 0.0f)); ensure_equals("addPointLocal max (4)", bbox1.getMaxLocal(), LLVector3(10.0f, 10.0f, 10.0f)); }
void LLTemplateMessageBuilderTestObject::test<14>() // Quaternion { LLMessageTemplate messageTemplate = defaultTemplate(); messageTemplate.addBlock(defaultBlock(MVT_LLQuaternion, 12)); LLQuaternion outValue, inValue = LLQuaternion(1,2,3,0); LLTemplateMessageBuilder* builder = defaultBuilder(messageTemplate); builder->addQuat(_PREHASH_Test0, inValue); LLTemplateMessageReader* reader = setReader(messageTemplate, builder); reader->getQuat(_PREHASH_Test0, _PREHASH_Test0, outValue); ensure_equals("Ensure LLQuaternion", inValue, outValue); delete reader; }
void LLWLParamManager::update(LLViewerCamera * cam) { LLFastTimer ftm(FTM_UPDATE_WLPARAM); // update clouds, sun, and general mCurParams.updateCloudScrolling(); // update only if running if(mAnimator.getIsRunning()) { mAnimator.update(mCurParams); } // update the shaders and the menu propagateParameters(); // sync menus if they exist if(LLFloaterWindLight::isOpen()) { LLFloaterWindLight::instance()->syncMenu(); } if(LLFloaterDayCycle::isOpen()) { LLFloaterDayCycle::instance()->syncMenu(); } if(LLFloaterEnvSettings::isOpen()) { LLFloaterEnvSettings::instance()->syncMenu(); } F32 camYaw = cam->getYaw(); stop_glerror(); // *TODO: potential optimization - this block may only need to be // executed some of the time. For example for water shaders only. { F32 camYawDelta = mSunDeltaYaw * DEG_TO_RAD; LLVector3 lightNorm3(mLightDir); lightNorm3 *= LLQuaternion(-(camYaw + camYawDelta), LLVector3(0.f, 1.f, 0.f)); mRotatedLightDir = LLVector4(lightNorm3, 0.f); std::vector<LLGLSLShader*>::iterator shaders_iter=mShaderList.begin(); for(; shaders_iter != mShaderList.end(); ++shaders_iter) { (*shaders_iter)->mUniformsDirty = TRUE; } } }
void object::test<15>() { // // test the containsPointLocal() method // LLBBox bbox1(LLVector3(1.0f, 1.0f, 1.0f), LLQuaternion(), LLVector3(1.0f, 2.0f, 3.0f), LLVector3(3.0f, 4.0f, 5.0f)); ensure("containsPointLocal(0,0,0)", bbox1.containsPointLocal(LLVector3(0.0f, 0.0f, 0.0f)) == FALSE); ensure("containsPointLocal(1,2,3)", bbox1.containsPointLocal(LLVector3(1.0f, 2.0f, 3.0f)) == TRUE); ensure("containsPointLocal(0.999,2,3)", bbox1.containsPointLocal(LLVector3(0.999f, 2.0f, 3.0f)) == FALSE); ensure("containsPointLocal(3,4,5)", bbox1.containsPointLocal(LLVector3(3.0f, 4.0f, 5.0f)) == TRUE); ensure("containsPointLocal(3,4,5.001)", bbox1.containsPointLocal(LLVector3(3.0f, 4.0f, 5.001f)) == FALSE); }
void object::test<16>() { // // test the containsPointAgent() method // LLBBox bbox1(LLVector3(1.0f, 1.0f, 1.0f), LLQuaternion(), LLVector3(1.0f, 2.0f, 3.0f), LLVector3(3.0f, 4.0f, 5.0f)); ensure("containsPointAgent(0,0,0)", bbox1.containsPointAgent(LLVector3(0.0f, 0.0f, 0.0f)) == FALSE); ensure("containsPointAgent(2,3,4)", bbox1.containsPointAgent(LLVector3(2.0f, 3.0f, 4.0f)) == TRUE); ensure("containsPointAgent(2,2.999,4)", bbox1.containsPointAgent(LLVector3(2.0f, 2.999f, 4.0f)) == FALSE); ensure("containsPointAgent(4,5,6)", bbox1.containsPointAgent(LLVector3(4.0f, 5.0f, 6.0f)) == TRUE); ensure("containsPointAgent(4,5.001,6)", bbox1.containsPointAgent(LLVector3(4.0f, 5.001f, 6.0f)) == FALSE); }
void ImportTracker::wear(LLSD &prim) { LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_ObjectAttach); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() ); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->addU8Fast(_PREHASH_AttachmentPoint, U8(prim["Attachment"].asInteger())); msg->nextBlockFast(_PREHASH_ObjectData); msg->addU32Fast(_PREHASH_ObjectLocalID, prim["LocalID"].asInteger()); msg->addQuatFast(_PREHASH_Rotation, LLQuaternion(0.0f, 0.0f, 0.0f, 1.0f)); msg->sendReliable(gAgent.getRegion()->getHost()); LLVector3 position = prim["attachpos"]; LLSD rot = prim["attachrot"]; LLQuaternion rotq; rotq.mQ[VX] = (F32)(rot[0].asReal()); rotq.mQ[VY] = (F32)(rot[1].asReal()); rotq.mQ[VZ] = (F32)(rot[2].asReal()); rotq.mQ[VW] = (F32)(rot[3].asReal()); LLVector3 rotation = rotq.packToVector3(); U8 data[256]; LLMessageSystem* msg2 = gMessageSystem; msg2->newMessageFast(_PREHASH_MultipleObjectUpdate); msg2->nextBlockFast(_PREHASH_AgentData); msg2->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg2->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg2->nextBlockFast(_PREHASH_ObjectData); msg2->addU32Fast(_PREHASH_ObjectLocalID, prim["LocalID"].asInteger()); msg2->addU8Fast(_PREHASH_Type, U8(0x01 | 0x08)); htonmemcpy(&data[0], &(position.mV), MVT_LLVector3, 12); msg2->addBinaryDataFast(_PREHASH_Data, data, 12); msg2->nextBlockFast(_PREHASH_ObjectData); msg2->addU32Fast(_PREHASH_ObjectLocalID, prim["LocalID"].asInteger()); msg2->addU8Fast(_PREHASH_Type, U8(0x02 | 0x08)); htonmemcpy(&data[0], &(rotation.mV), MVT_LLQuaternion, 12); msg2->addBinaryDataFast(_PREHASH_Data, data, 12); msg2->sendReliable(gAgent.getRegion()->getHost()); llinfos << "POSITIONED, IMPORT COMPLETED" << llendl; cleanUp(); }
// Returns the necessary texture transform to align this face's TE to align_to's TE bool LLFace::calcAlignedPlanarTE(const LLFace* align_to, LLVector2* res_st_offset, LLVector2* res_st_scale, F32* res_st_rot) const { if (!align_to) { return false; } const LLTextureEntry *orig_tep = align_to->getTextureEntry(); if ((orig_tep->getTexGen() != LLTextureEntry::TEX_GEN_PLANAR) || (getTextureEntry()->getTexGen() != LLTextureEntry::TEX_GEN_PLANAR)) { return false; } LLVector3 orig_pos, this_pos; LLQuaternion orig_face_rot, this_face_rot; F32 orig_proj_scale, this_proj_scale; align_to->getPlanarProjectedParams(&orig_face_rot, &orig_pos, &orig_proj_scale); getPlanarProjectedParams(&this_face_rot, &this_pos, &this_proj_scale); // The rotation of "this face's" texture: LLQuaternion orig_st_rot = LLQuaternion(orig_tep->getRotation(), LLVector3::z_axis) * orig_face_rot; LLQuaternion this_st_rot = orig_st_rot * ~this_face_rot; F32 x_ang, y_ang, z_ang; this_st_rot.getEulerAngles(&x_ang, &y_ang, &z_ang); *res_st_rot = z_ang; // Offset and scale of "this face's" texture: LLVector3 centers_dist = (this_pos - orig_pos) * ~orig_st_rot; LLVector3 st_scale(orig_tep->mScaleS, orig_tep->mScaleT, 1.f); st_scale *= orig_proj_scale; centers_dist.scaleVec(st_scale); LLVector2 orig_st_offset(orig_tep->mOffsetS, orig_tep->mOffsetT); *res_st_offset = orig_st_offset + (LLVector2)centers_dist; res_st_offset->mV[VX] -= (S32)res_st_offset->mV[VX]; res_st_offset->mV[VY] -= (S32)res_st_offset->mV[VY]; st_scale /= this_proj_scale; *res_st_scale = (LLVector2)st_scale; return true; }
//-------------------------------------------------------------------- // setWorldRotation() //-------------------------------------------------------------------- void LLJoint::setWorldRotation( const LLQuaternion& rot ) { if (mParent == NULL) { this->setRotation( rot ); return; } LLMatrix4a parentWorldMatrix = mParent->getWorldMatrix(); LLQuaternion2 rota(rot); LLMatrix4a temp_mat(rota); LLMatrix4a invParentWorldMatrix = mParent->getWorldMatrix(); invParentWorldMatrix.setTranslate_affine(LLVector3(0.f)); invParentWorldMatrix.invert(); invParentWorldMatrix.mul(temp_mat); setRotation(LLQuaternion(LLMatrix4(invParentWorldMatrix.getF32ptr()))); }