void LLWorld::updateVisibilities() { F32 cur_far_clip = LLViewerCamera::getInstance()->getFar(); LLViewerCamera::getInstance()->setFar(mLandFarClip); F32 diagonal_squared = F_SQRT2 * F_SQRT2 * mWidth * mWidth; // Go through the culled list and check for visible regions for (region_list_t::iterator iter = mCulledRegionList.begin(); iter != mCulledRegionList.end(); ) { region_list_t::iterator curiter = iter++; LLViewerRegion* regionp = *curiter; F32 height = regionp->getLand().getMaxZ() - regionp->getLand().getMinZ(); F32 radius = 0.5f*fsqrtf(height * height + diagonal_squared); if (!regionp->getLand().hasZData() || LLViewerCamera::getInstance()->sphereInFrustum(regionp->getCenterAgent(), radius)) { mCulledRegionList.erase(curiter); mVisibleRegionList.push_back(regionp); } } // Update all of the visible regions for (region_list_t::iterator iter = mVisibleRegionList.begin(); iter != mVisibleRegionList.end(); ) { region_list_t::iterator curiter = iter++; LLViewerRegion* regionp = *curiter; if (!regionp->getLand().hasZData()) { continue; } F32 height = regionp->getLand().getMaxZ() - regionp->getLand().getMinZ(); F32 radius = 0.5f*fsqrtf(height * height + diagonal_squared); if (LLViewerCamera::getInstance()->sphereInFrustum(regionp->getCenterAgent(), radius)) { regionp->calculateCameraDistance(); if (!gNoRender) { regionp->getLand().updatePatchVisibilities(gAgent); } } else { mVisibleRegionList.erase(curiter); mCulledRegionList.push_back(regionp); } } // Sort visible regions mVisibleRegionList.sort(LLViewerRegion::CompareDistance()); LLViewerCamera::getInstance()->setFar(cur_far_clip); }
void v4color_object::test<6>() { F32 r = 0x20, g = 0xFFFF, b = 0xFF; LLColor4 llcolor4(r,g,b); ensure("magVecSquared:Fail ", is_approx_equal(llcolor4.magVecSquared(), (r*r + g*g + b*b))); ensure("magVec:Fail ", is_approx_equal(llcolor4.magVec(), fsqrtf(r*r + g*g + b*b))); }
void v3math_object::test<8>() { F32 x = 2.32f, y = 1.212f, z = -.12f; LLVector3 vec3(x,y,z); ensure("1:magVecSquared:Fail ", is_approx_equal(vec3.magVecSquared(), (x*x + y*y + z*z))); ensure("2:magVec:Fail ", is_approx_equal(vec3.magVec(), fsqrtf(x*x + y*y + z*z))); }
void v3color_object::test<4>() { F32 r = 2.3436212f, g = 1231.f, b = 4.7849321232f; LLColor3 llcolor3(r,g,b); ensure("magVecSquared:Fail ", is_approx_equal(llcolor3.magVecSquared(), (r*r + g*g + b*b))); ensure("magVec:Fail ", is_approx_equal(llcolor3.magVec(), fsqrtf(r*r + g*g + b*b))); }
void v2math_object::test<3>() { F32 x = 2.2345f, y = 3.5678f ; LLVector2 vec2(x,y); ensure("magVecSquared:Fail ", is_approx_equal(vec2.magVecSquared(), (x*x + y*y))); ensure("magVec:Fail ", is_approx_equal(vec2.magVec(), fsqrtf(x*x + y*y))); }
void v4math_object::test<3>() { F32 x = 10.f, y = -2.3f, z = -.023f; LLVector4 vec4(x,y,z); ensure("magVec:Fail ", is_approx_equal(vec4.magVec(), fsqrtf(x*x + y*y + z*z))); ensure("magVecSquared:Fail ", is_approx_equal(vec4.magVecSquared(), (x*x + y*y + z*z))); }
void v4coloru_object::test<7>() { U8 r = 0x12, g = 0xFF, b = 0xAF; LLColor4U llcolor4u(r,g,b); ensure("magVecSquared:Fail ", is_approx_equal(llcolor4u.magVecSquared(), (F32)(r*r + g*g + b*b))); ensure("magVec:Fail ", is_approx_equal(llcolor4u.magVec(), fsqrtf(r*r + g*g + b*b))); }
void v3dmath_object::test<18>() { F64 x = 1., y = 2., z = -1.1; LLVector3d vec3D(x,y,z); F64 res = (x*x + y*y + z*z) - vec3D.magVecSquared(); ensure("1:magVecSquared:Fail ", ((-F_APPROXIMATELY_ZERO <= res)&& (res <=F_APPROXIMATELY_ZERO))); res = fsqrtf(x*x + y*y + z*z) - vec3D.magVec(); ensure("2:magVec: Fail ", ((-F_APPROXIMATELY_ZERO <= res)&& (res <=F_APPROXIMATELY_ZERO))); }
void v3color_object::test<19>() { F32 r1 =1.f, g1 = 2.f,b1 = 1.2f, r2 = -2.3f, g2 = 1.11f, b2 = 1234.234f; LLColor3 llcolor3(r1,g1,b1),llcolor3a(r2,g2,b2); F32 val = distVec(llcolor3,llcolor3a); ensure("distVec failed ", is_approx_equal(fsqrtf((r1-r2)*(r1-r2) + (g1-g2)*(g1-g2) + (b1-b2)*(b1-b2)) ,val)); F32 val1 = distVec_squared(llcolor3,llcolor3a); ensure("distVec_squared failed ", is_approx_equal(((r1-r2)*(r1-r2) + (g1-g2)*(g1-g2) + (b1-b2)*(b1-b2)) ,val1)); }
void v4color_object::test<7>() { F32 r = 0x20, g = 0xFFFF, b = 0xFF; LLColor4 llcolor4(r,g,b); F32 vecMag = llcolor4.normVec(); F32 mag = fsqrtf(r*r + g*g + b*b); F32 oomag = 1.f / mag; F32 val1 = r * oomag, val2 = g * oomag, val3 = b * oomag; ensure("1:normVec failed ", (is_approx_equal(val1, llcolor4.mV[0]) && is_approx_equal(val2, llcolor4.mV[1]) && is_approx_equal(val3, llcolor4.mV[2]) && is_approx_equal(vecMag, mag))); }
void v4math_object::test<19>() { F32 x1 =-2.3f, y1 = 2.f,z1 = 1.2f, x2 = 1.3f, y2 = 1.f, z2 = 1.f; F32 val1,val2; LLVector4 vec4(x1,y1,z1),vec4a(x2,y2,z2); val1 = dist_vec(vec4,vec4a); val2 = fsqrtf((x1 - x2)*(x1 - x2) + (y1 - y2)* (y1 - y2) + (z1 - z2)* (z1 -z2)); ensure_equals("dist_vec: Fail ",val2, val1); val1 = dist_vec_squared(vec4,vec4a); val2 =((x1 - x2)*(x1 - x2) + (y1 - y2)* (y1 - y2) + (z1 - z2)* (z1 -z2)); ensure_equals("dist_vec_squared: Fail ",val2, val1); }
void LLVOTree::updateTextures() { if (mTreeImagep) { if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA)) { setDebugText(llformat("%4.0f", fsqrtf(mPixelArea))); } mTreeImagep->addTextureStats(mPixelArea); } }
static float v_sol(const float p[3], const float v[3], float r) { float a = v_dot(v, v); float b = v_dot(v, p) * 2.0f; float c = v_dot(p, p) - r * r; float d = b * b - 4.0f * a * c; /* Testing for equality against zero is acceptable. */ if (a == 0.0f) return LARGE; if (d < 0.0f) return LARGE; else if (d > 0.0f) { float t0 = 0.5f * (-b - fsqrtf(d)) / a; float t1 = 0.5f * (-b + fsqrtf(d)) / a; float t = (t0 < t1) ? t0 : t1; return (t < 0.0f) ? LARGE : t; } else return -b * 0.5f / a; }
void v3math_object::test<31>() { F32 x1 =-2.3f, y1 = 2.f,z1 = 1.2f, x2 = 1.3f, y2 = 1.f, z2 = 1.f; F32 val1,val2; LLVector3 vec3(x1,y1,z1),vec3a(x2,y2,z2); val1 = dist_vec(vec3,vec3a); val2 = fsqrtf((x1 - x2)*(x1 - x2) + (y1 - y2)* (y1 - y2) + (z1 - z2)* (z1 -z2)); ensure_equals("1:dist_vec: Fail ",val2, val1); val1 = dist_vec_squared(vec3,vec3a); val2 =((x1 - x2)*(x1 - x2) + (y1 - y2)* (y1 - y2) + (z1 - z2)* (z1 -z2)); ensure_equals("2:dist_vec_squared: Fail ",val2, val1); val1 = dist_vec_squared2D(vec3, vec3a); val2 =(x1 - x2)*(x1 - x2) + (y1 - y2)* (y1 - y2); ensure_equals("3:dist_vec_squared2D: Fail ",val2, val1); }
void v2math_object::test<21>() { F32 x1 =1.f, y1 = 2.f, x2 = -.32f, y2 = .2234f; F32 val1, val2; LLVector2 vec2(x1, y1),vec3(x2, y2); val1 = dist_vec_squared2D(vec2, vec3); val2 = (x1 - x2)*(x1 - x2) + (y1 - y2)* (y1 - y2); ensure_equals("dist_vec_squared2D values are not equal",val2, val1); val1 = dist_vec_squared(vec2, vec3); ensure_equals("dist_vec_squared values are not equal",val2, val1); val1 = dist_vec(vec2, vec3); val2 = fsqrtf((x1 - x2)*(x1 - x2) + (y1 - y2)* (y1 - y2)); ensure_equals("dist_vec values are not equal",val2, val1); }
void v3color_object::test<5>() { F32 r = 2.3436212f, g = 1231.f, b = 4.7849321232f; F32 val1, val2,val3; LLColor3 llcolor3(r,g,b); F32 vecMag = llcolor3.normVec(); F32 mag = fsqrtf(r*r + g*g + b*b); F32 oomag = 1.f / mag; val1 = r * oomag; val2 = g * oomag; val3 = b * oomag; ensure("1:normVec failed ", (is_approx_equal(val1, llcolor3.mV[0]) && is_approx_equal(val2, llcolor3.mV[1]) && is_approx_equal(val3, llcolor3.mV[2]) && is_approx_equal(vecMag, mag))); r = .000000000f, g = 0.f, b = 0.0f; llcolor3.setVec(r,g,b); vecMag = llcolor3.normVec(); ensure("2:normVec failed should be 0. ", (0. == llcolor3.mV[0] && 0. == llcolor3.mV[1] && 0. == llcolor3.mV[2] && vecMag == 0.)); }
void v2math_object::test<23>() { F32 x1 =1.f, y1 = 2.f; F32 val1, val2; LLVector2 vec2(x1, y1); F32 vecMag = vec2.normVec(); F32 mag = fsqrtf(x1*x1 + y1*y1); F32 oomag = 1.f / mag; val1 = x1 * oomag; val2 = y1 * oomag; ensure("normVec failed", is_approx_equal(val1, vec2.mV[VX]) && is_approx_equal(val2, vec2.mV[VY]) && is_approx_equal(vecMag, mag)); x1 =.00000001f, y1 = 0.f; vec2.setVec(x1, y1); vecMag = vec2.normVec(); ensure("normVec failed should be 0.", 0. == vec2.mV[VX] && 0. == vec2.mV[VY] && vecMag == 0.); }
BOOL LLBreastMotion::onUpdate(F32 time, U8* joint_mask) { // Skip if disabled globally. if (!gSavedSettings.getBOOL("AvatarPhysics")) { return TRUE; } // Higher LOD is better. This controls the granularity // and frequency of updates for the motions. const F32 lod_factor = LLVOAvatar::sPhysicsLODFactor; if (lod_factor == 0) { return TRUE; } if (mCharacter->getSex() != SEX_FEMALE) return TRUE; const F32 time_delta = calculateTimeDelta(); if (time_delta < .01 || time_delta > 10.0) return TRUE; //////////////////////////////////////////////////////////////////////////////// // Get all parameters and settings // mBreastMassParam = mCharacter->getVisualParamWeight("Breast_Physics_Mass"); mBreastSmoothingParam = (U32)(mCharacter->getVisualParamWeight("Breast_Physics_Smoothing")); mBreastGravityParam = mCharacter->getVisualParamWeight("Breast_Physics_Gravity"); mBreastSpringParam[0] = mCharacter->getVisualParamWeight("Breast_Physics_Side_Spring"); mBreastGainParam[0] = mCharacter->getVisualParamWeight("Breast_Physics_Side_Gain"); mBreastDampingParam[0] = mCharacter->getVisualParamWeight("Breast_Physics_Side_Damping"); mBreastMaxVelocityParam[0] = mCharacter->getVisualParamWeight("Breast_Physics_Side_Max_Velocity"); mBreastDragParam[0] = mCharacter->getVisualParamWeight("Breast_Physics_Side_Drag"); mBreastSpringParam[1] = mCharacter->getVisualParamWeight("Breast_Physics_UpDown_Spring"); mBreastGainParam[1] = mCharacter->getVisualParamWeight("Breast_Physics_UpDown_Gain"); mBreastDampingParam[1] = mCharacter->getVisualParamWeight("Breast_Physics_UpDown_Damping"); mBreastMaxVelocityParam[1] = mCharacter->getVisualParamWeight("Breast_Physics_UpDown_Max_Velocity"); mBreastDragParam[1] = mCharacter->getVisualParamWeight("Breast_Physics_UpDown_Drag"); // Get the current morph parameters. LLVector3 breast_user_local_pt(0,0,0); for (U32 i=0; i < N_PARAMS; i++) { if (mBreastParamsUser[i] != NULL) { breast_user_local_pt[i] = mBreastParamsUser[i]->getWeight(); } } LLVector3 breast_current_local_pt = mBreastLastPosition_local_pt; // // End parameters and settings //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // Calculate velocity and acceleration in parameter space. // const LLVector3 char_velocity_local_vec = calculateVelocity_local(time_delta); const LLVector3 char_acceleration_local_vec = calculateAcceleration_local(char_velocity_local_vec, time_delta); mCharLastVelocity_local_vec = char_velocity_local_vec; LLJoint *chest_joint = mChestState->getJoint(); mCharLastPosition_world_pt = chest_joint->getWorldPosition(); // // End velocity and acceleration //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // Calculate the total force // // Spring force is a restoring force towards the original user-set breast position. // F = kx const LLVector3 spring_length_local = breast_current_local_pt-breast_user_local_pt; LLVector3 force_spring_local_vec = -spring_length_local; force_spring_local_vec *= mBreastSpringParam; // Acceleration is the force that comes from the change in velocity of the torso. // F = ma + mg LLVector3 force_accel_local_vec = char_acceleration_local_vec * mBreastMassParam; const LLVector3 force_gravity_local_vec = toLocal(LLVector3(0,0,1))* mBreastGravityParam * mBreastMassParam; force_accel_local_vec += force_gravity_local_vec; force_accel_local_vec *= mBreastGainParam; // Damping is a restoring force that opposes the current velocity. // F = -kv LLVector3 force_damping_local_vec = -mBreastDampingParam; force_damping_local_vec *= mBreastVelocity_local_vec; // Drag is a force imparted by velocity, intuitively it is similar to wind resistance. // F = .5v*v LLVector3 force_drag_local_vec = .5*char_velocity_local_vec; force_drag_local_vec *= char_velocity_local_vec; force_drag_local_vec *= mBreastDragParam[0]; LLVector3 force_net_local_vec = force_accel_local_vec + force_gravity_local_vec + force_spring_local_vec + force_damping_local_vec + force_drag_local_vec; // // End total force //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // Calculate new params // // Calculate the new acceleration based on the net force. // a = F/m LLVector3 acceleration_local_vec = force_net_local_vec / mBreastMassParam; mBreastVelocity_local_vec += acceleration_local_vec; mBreastVelocity_local_vec.clamp(-mBreastMaxVelocityParam*100.0, mBreastMaxVelocityParam*100.0); // Temporary debugging setting to cause all avatars to move, for profiling purposes. if (gSavedSettings.getBOOL("AvatarPhysicsTest")) { mBreastVelocity_local_vec[0] = sin(mTimer.getElapsedTimeF32()*4.0)*5.0; mBreastVelocity_local_vec[1] = sin(mTimer.getElapsedTimeF32()*3.0)*5.0; } // Calculate the new parameters and clamp them to the min/max ranges. LLVector3 new_local_pt = breast_current_local_pt + mBreastVelocity_local_vec*time_delta; new_local_pt.clamp(mBreastParamsMin,mBreastParamsMax); // Set the new parameters. for (U32 i=0; i < 3; i++) { // If the param is disabled, just set the param to the user value. if (mBreastMaxVelocityParam[i] == 0) { new_local_pt[i] = breast_user_local_pt[i]; } if (mBreastParamsDriven[i]) { mCharacter->setVisualParamWeight(mBreastParamsDriven[i], new_local_pt[i], FALSE); } } mBreastLastPosition_local_pt = new_local_pt; // // End calculate new params //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // Conditionally update the visual params // // Updating the visual params (i.e. what the user sees) is fairly expensive. // So only update if the params have changed enough, and also take into account // the graphics LOD settings. // For non-self, if the avatar is small enough visually, then don't update. const BOOL is_self = (dynamic_cast<LLVOAvatarSelf *>(this) != NULL); if (!is_self) { const F32 area_for_max_settings = 0.0; const F32 area_for_min_settings = 1400.0; const F32 area_for_this_setting = area_for_max_settings + (area_for_min_settings-area_for_max_settings)*(1.0-lod_factor); const F32 pixel_area = fsqrtf(mCharacter->getPixelArea()); if (pixel_area < area_for_this_setting) { return TRUE; } } // If the parameter hasn't changed enough, then don't update. LLVector3 position_diff = mBreastLastUpdatePosition_local_pt-new_local_pt; for (U32 i=0; i < 3; i++) { const F32 min_delta = (1.0-lod_factor)*(mBreastParamsMax[i]-mBreastParamsMin[i])/2.0; if (llabs(position_diff[i]) > min_delta) { mCharacter->updateVisualParams(); mBreastLastUpdatePosition_local_pt = new_local_pt; return TRUE; } } // // End update visual params //////////////////////////////////////////////////////////////////////////////// return TRUE; }
// ----------------------------------------------------------------------------- void LLViewerJoystick::moveAvatar(bool reset) { if (!gFocusMgr.getAppHasFocus() || mDriverState != JDS_INITIALIZED || !gSavedSettings.getBOOL("JoystickEnabled") || !gSavedSettings.getBOOL("JoystickAvatarEnabled")) { return; } S32 axis[] = { // [1 0 2 4 3 5] // [Z X Y RZ RX RY] gSavedSettings.getS32("JoystickAxis0"), gSavedSettings.getS32("JoystickAxis1"), gSavedSettings.getS32("JoystickAxis2"), gSavedSettings.getS32("JoystickAxis3"), gSavedSettings.getS32("JoystickAxis4"), gSavedSettings.getS32("JoystickAxis5") }; if (reset || mResetFlag) { resetDeltas(axis); if (reset) { // Note: moving the agent triggers agent camera mode; // don't do this every time we set mResetFlag (e.g. because we gained focus) gAgent.moveAt(0, true); } return; } bool is_zero = true; static bool button_held = false; if (mBtn[1] == 1) { // If AutomaticFly is enabled, then button1 merely causes a // jump (as the up/down axis already controls flying) if on the // ground, or cease flight if already flying. // If AutomaticFly is disabled, then button1 toggles flying. static LLCachedControl<bool> AutomaticFly(gSavedSettings,"AutomaticFly"); if (AutomaticFly) { if (!gAgent.getFlying()) { gAgent.moveUp(1); } else if (!button_held) { button_held = true; gAgent.setFlying(FALSE); } } else if (!button_held) { button_held = true; gAgent.setFlying(!gAgent.getFlying()); } is_zero = false; } else { button_held = false; } F32 axis_scale[] = { gSavedSettings.getF32("AvatarAxisScale0"), gSavedSettings.getF32("AvatarAxisScale1"), gSavedSettings.getF32("AvatarAxisScale2"), gSavedSettings.getF32("AvatarAxisScale3"), gSavedSettings.getF32("AvatarAxisScale4"), gSavedSettings.getF32("AvatarAxisScale5") }; F32 dead_zone[] = { gSavedSettings.getF32("AvatarAxisDeadZone0"), gSavedSettings.getF32("AvatarAxisDeadZone1"), gSavedSettings.getF32("AvatarAxisDeadZone2"), gSavedSettings.getF32("AvatarAxisDeadZone3"), gSavedSettings.getF32("AvatarAxisDeadZone4"), gSavedSettings.getF32("AvatarAxisDeadZone5") }; // time interval in seconds between this frame and the previous F32 time = gFrameIntervalSeconds; // avoid making ridicously big movements if there's a big drop in fps if (time > .2f) { time = .2f; } // note: max feather is 32.0 F32 feather = gSavedSettings.getF32("AvatarFeathering"); F32 cur_delta[6]; F32 val, dom_mov = 0.f; U32 dom_axis = Z_I; #if LIB_NDOF bool absolute = (gSavedSettings.getBOOL("Cursor3D") && mNdofDev->absolute); #else bool absolute = false; #endif // remove dead zones and determine biggest movement on the joystick for (U32 i = 0; i < 6; i++) { cur_delta[i] = -mAxes[axis[i]]; if (absolute) { F32 tmp = cur_delta[i]; cur_delta[i] = cur_delta[i] - sLastDelta[i]; sLastDelta[i] = tmp; } if (cur_delta[i] > 0) { cur_delta[i] = llmax(cur_delta[i]-dead_zone[i], 0.f); } else { cur_delta[i] = llmin(cur_delta[i]+dead_zone[i], 0.f); } // we don't care about Roll (RZ) and Z is calculated after the loop if (i != Z_I && i != RZ_I) { // find out the axis with the biggest joystick motion val = fabs(cur_delta[i]); if (val > dom_mov) { dom_axis = i; dom_mov = val; } } is_zero = is_zero && (cur_delta[i] == 0.f); } if (!is_zero) { // Clear AFK state if moved beyond the deadzone if (gAwayTimer.getElapsedTimeF32() > MIN_AFK_TIME) { gAgent.clearAFK(); } setCameraNeedsUpdate(true); } // forward|backward movements overrule the real dominant movement if // they're bigger than its 20%. This is what you want 'cos moving forward // is what you do most. We also added a special (even more lenient) case // for RX|RY to allow walking while pitching and turning if (fabs(cur_delta[Z_I]) > .2f * dom_mov || ((dom_axis == RX_I || dom_axis == RY_I) && fabs(cur_delta[Z_I]) > .05f * dom_mov)) { dom_axis = Z_I; } sDelta[X_I] = -cur_delta[X_I] * axis_scale[X_I]; sDelta[Y_I] = -cur_delta[Y_I] * axis_scale[Y_I]; sDelta[Z_I] = -cur_delta[Z_I] * axis_scale[Z_I]; cur_delta[RX_I] *= -axis_scale[RX_I] * mPerfScale; cur_delta[RY_I] *= -axis_scale[RY_I] * mPerfScale; if (!absolute) { cur_delta[RX_I] *= time; cur_delta[RY_I] *= time; } sDelta[RX_I] += (cur_delta[RX_I] - sDelta[RX_I]) * time * feather; sDelta[RY_I] += (cur_delta[RY_I] - sDelta[RY_I]) * time * feather; handleRun(fsqrtf(sDelta[Z_I]*sDelta[Z_I] + sDelta[X_I]*sDelta[X_I])); // Allow forward/backward movement some priority if (dom_axis == Z_I) { agentPush(sDelta[Z_I]); // forward/back if (fabs(sDelta[X_I]) > .1f) { agentSlide(sDelta[X_I]); // move sideways } if (fabs(sDelta[Y_I]) > .1f) { agentFly(sDelta[Y_I]); // up/down & crouch } // too many rotations during walking can be confusing, so apply // the deadzones one more time (quick & dirty), at 50%|30% power F32 eff_rx = .3f * dead_zone[RX_I]; F32 eff_ry = .3f * dead_zone[RY_I]; if (sDelta[RX_I] > 0) { eff_rx = llmax(sDelta[RX_I] - eff_rx, 0.f); } else { eff_rx = llmin(sDelta[RX_I] + eff_rx, 0.f); } if (sDelta[RY_I] > 0) { eff_ry = llmax(sDelta[RY_I] - eff_ry, 0.f); } else { eff_ry = llmin(sDelta[RY_I] + eff_ry, 0.f); } if (fabs(eff_rx) > 0.f || fabs(eff_ry) > 0.f) { if (gAgent.getFlying()) { agentPitch(eff_rx); agentYaw(eff_ry); } else { agentPitch(eff_rx); agentYaw(2.f * eff_ry); } } } else { agentSlide(sDelta[X_I]); // move sideways agentFly(sDelta[Y_I]); // up/down & crouch agentPush(sDelta[Z_I]); // forward/back agentPitch(sDelta[RX_I]); // pitch agentYaw(sDelta[RY_I]); // turn } }
void game_draw(int pose, float t) { static const float a[4] = { 0.2f, 0.2f, 0.2f, 1.0f }; static const float s[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; static const float e[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; static const float h[1] = { 0.0f }; const float light_p[4] = { 8.f, 32.f, 8.f, 1.f }; const struct s_file *fp = &file; float fov = FOV; if (jump_b) fov *= 2.0f * fabsf(jump_dt - 0.5f); video_push_persp(fov, 0.1f, FAR_DIST); glPushAttrib(GL_LIGHTING_BIT); glPushMatrix(); { float T[16], M[16], v[3], rx, ry; m_view(T, view_c, view_p, view_e[1]); m_xps(M, T); v_sub(v, view_c, view_p); rx = V_DEG(fatan2f(-v[1], fsqrtf(v[0] * v[0] + v[2] * v[2]))); ry = V_DEG(fatan2f(+v[0], -v[2])); glTranslatef(0.f, 0.f, -v_len(v)); glMultMatrixf(M); glTranslatef(-view_c[0], -view_c[1], -view_c[2]); /* Center the skybox about the position of the camera. */ glPushMatrix(); { glTranslatef(view_p[0], view_p[1], view_p[2]); back_draw(0); } glPopMatrix(); glEnable(GL_LIGHT0); glLightfv(GL_LIGHT0, GL_POSITION, light_p); /* Draw the floor. */ sol_draw(fp, 0, 1); if (config_get_d(CONFIG_SHADOW) && !pose) { shad_draw_set(fp->uv[ball].p, fp->uv[ball].r); sol_shad(fp); shad_draw_clr(); } /* Draw the game elements. */ glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); if (pose == 0) { game_draw_balls(fp, T, t); game_draw_vect(fp); } glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, a); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, s); glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, e); glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, h); game_draw_goals(fp); glEnable(GL_COLOR_MATERIAL); glDisable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); glDepthMask(GL_FALSE); { game_draw_jumps(fp); game_draw_swchs(fp); } glDepthMask(GL_TRUE); glEnable(GL_TEXTURE_2D); glEnable(GL_LIGHTING); glDisable(GL_COLOR_MATERIAL); } glPopMatrix(); glPopAttrib(); video_pop_matrix(); }
F32 dist_vec(const LLVector2 &a, const LLVector2 &b) { F32 x = a.mV[0] - b.mV[0]; F32 y = a.mV[1] - b.mV[1]; return fsqrtf( x*x + y*y ); }
void LLPanelNearByMedia::updateListItem(LLScrollListItem* item, LLViewerMediaImpl* impl) { std::string item_name; std::string item_tooltip; std::string debug_str; LLPanelNearByMedia::MediaClass media_class = MEDIA_CLASS_ALL; getNameAndUrlHelper(impl, item_name, item_tooltip, mEmptyNameString); // Focused if (impl->hasFocus()) { media_class = MEDIA_CLASS_FOCUSED; } // Is attached to another avatar? else if (impl->isAttachedToAnotherAvatar()) { media_class = MEDIA_CLASS_ON_OTHERS; } // Outside agent parcel else if (!impl->isInAgentParcel()) { media_class = MEDIA_CLASS_OUTSIDE_PARCEL; } else { // inside parcel media_class = MEDIA_CLASS_WITHIN_PARCEL; } if(mDebugInfoVisible) { debug_str += llformat("%g/", (float)impl->getInterest()); // proximity distance is actually distance squared -- display it as straight distance. debug_str += llformat("%g/", fsqrtf(impl->getProximityDistance())); // s += llformat("%g/", (float)impl->getCPUUsage()); // s += llformat("%g/", (float)impl->getApproximateTextureInterest()); debug_str += llformat("%g/", (float)(NULL == impl->getSomeObject()) ? 0.0 : impl->getSomeObject()->getPixelArea()); debug_str += LLPluginClassMedia::priorityToString(impl->getPriority()); if(impl->hasMedia()) { debug_str += '@'; } else if(impl->isPlayable()) { debug_str += '+'; } else if(impl->isForcedUnloaded()) { debug_str += '!'; } } updateListItem(item, item_name, item_tooltip, impl->getProximity(), impl->isMediaDisabled(), impl->hasMedia(), impl->isMediaTimeBased() && impl->isMediaPlaying(), media_class, debug_str); }
void game_draw(int pose, float st) { float fov = view_fov; if (jump_b) fov *= 2.f * fabsf(jump_dt - 0.5); if (game_state) { config_push_persp(fov, 0.1f, FAR_DIST); glPushMatrix(); { float v[3], rx, ry; float pup[3]; float pdn[3]; v_cpy(pup, view_p); v_cpy(pdn, view_p); pdn[1] = -pdn[1]; /* Compute and apply the view. */ v_sub(v, view_c, view_p); rx = V_DEG(fatan2f(-v[1], fsqrtf(v[0] * v[0] + v[2] * v[2]))); ry = V_DEG(fatan2f(+v[0], -v[2])) + st; glTranslatef(0.f, 0.f, -v_len(v)); glRotatef(rx, 1.f, 0.f, 0.f); glRotatef(ry, 0.f, 1.f, 0.f); glTranslatef(-view_c[0], -view_c[1], -view_c[2]); #ifndef DREAMCAST_KGL_NOT_IMPLEMENT if (config_get_d(CONFIG_REFLECTION)) { /* Draw the mirror only into the stencil buffer. */ glDisable(GL_DEPTH_TEST); glEnable(GL_STENCIL_TEST); glStencilFunc(GL_ALWAYS, 1, 0xFFFFFFFF); glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); game_refl_all(0); /* Draw the scene reflected into color and depth buffers. */ glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glStencilFunc(GL_EQUAL, 1, 0xFFFFFFFF); glEnable(GL_DEPTH_TEST); glFrontFace(GL_CW); glPushMatrix(); { glScalef(+1.f, -1.f, +1.f); game_draw_light(); game_draw_back(pose, -1, pdn); game_draw_fore(pose, rx, ry, -1, pdn); } glPopMatrix(); glFrontFace(GL_CCW); glDisable(GL_STENCIL_TEST); } #endif /* Draw the scene normally. */ game_draw_light(); game_refl_all(pose ? 0 : config_get_d(CONFIG_SHADOW)); game_draw_back(pose, +1, pup); game_draw_fore(pose, rx, ry, +1, pup); } glPopMatrix(); config_pop_matrix(); /* Draw the fade overlay. */ fade_draw(fade_k); } }
void game_draw(int pose, float t) { const float light_p[4] = { 8.f, 32.f, 8.f, 0.f }; struct s_draw *fp = &file.draw; struct s_rend rend; float fov = FOV; if (!state) return; fp->shadow_ui = ball; game_shadow_conf(1); sol_draw_enable(&rend); if (jump_b) fov *= 2.0f * fabsf(jump_dt - 0.5f); video_push_persp(fov, 0.1f, FAR_DIST); glPushMatrix(); { float T[16], M[16], v[3], rx, ry; m_view(T, view_c, view_p, view_e[1]); m_xps(M, T); v_sub(v, view_c, view_p); rx = V_DEG(fatan2f(-v[1], fsqrtf(v[0] * v[0] + v[2] * v[2]))); ry = V_DEG(fatan2f(+v[0], -v[2])); glTranslatef(0.f, 0.f, -v_len(v)); glMultMatrixf(M); glTranslatef(-view_c[0], -view_c[1], -view_c[2]); /* Center the skybox about the position of the camera. */ glPushMatrix(); { glTranslatef(view_p[0], view_p[1], view_p[2]); back_draw(&rend, 0); } glPopMatrix(); glEnable(GL_LIGHT0); glLightfv(GL_LIGHT0, GL_POSITION, light_p); /* Draw the floor. */ sol_draw(fp, &rend, 0, 1); /* Draw the game elements. */ glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); if (pose == 0) { game_draw_balls(&rend, fp->vary, T, t); game_draw_vect(&rend, fp->vary); } glDisable(GL_LIGHTING); glDepthMask(GL_FALSE); { game_draw_goals(&rend, fp->base); game_draw_jumps(&rend, fp->base); game_draw_swchs(&rend, fp->vary); } glDepthMask(GL_TRUE); glEnable(GL_LIGHTING); } glPopMatrix(); video_pop_matrix(); sol_draw_disable(&rend); game_shadow_conf(0); }