void CEditShape::Attach(CEditShape* from) { ApplyScale (); // transfer data from->ApplyScale (); Fmatrix M = from->_Transform(); M.mulA_43 (_ITransform()); for (ShapeIt it=from->shapes.begin(); it!=from->shapes.end(); it++){ switch (it->type){ case cfSphere:{ Fsphere& T = it->data.sphere; M.transform_tiny(T.P); add_sphere (T); }break; case cfBox:{ Fmatrix B = it->data.box; B.mulA_43 (M); add_box (B); }break; default: THROW; } } // common Scene->RemoveObject (from,true,true); xr_delete (from); ComputeBounds (); }
void Entity::SetScale(glm::vec3 scale) { for (int col = 0; col < 3; col++) for (int row = 0; row < 3; row++) toWorld[col][row] /= this->scale[col]; this->scale = scale; ApplyScale(); }
void Entity::RotateTo(const glm::mat3 & newOrientation) { glm::mat4 temp = glm::mat4(newOrientation); temp[3] = toWorld[3]; toWorld = std::move(temp); ApplyScale(); CalculateNormalMatrix(); }
void Entity::RotateTo(const glm::quat & newOrientation) { glm::mat4 temp = static_cast<glm::mat4>(glm::quat(newOrientation)); temp[3] = toWorld[3]; toWorld = std::move(temp); // Add scale ApplyScale(); CalculateNormalMatrix(); }
drape_ptr<MapScaleAnimation> GetScaleAnimation(ScreenBase const & startScreen, m2::PointD pxScaleCenter, m2::PointD glbScaleCenter, double factor) { ScreenBase endScreen = startScreen; ApplyScale(pxScaleCenter, factor, endScreen); auto anim = make_unique_dp<MapScaleAnimation>(startScreen.GetScale(), endScreen.GetScale(), glbScaleCenter, pxScaleCenter); anim->SetMaxDuration(kMaxAnimationTimeSec); return anim; }
void CEditShape::Detach() { if (shapes.size()>1){ Select (true); ApplyScale (); // create scene shapes const Fmatrix& M = _Transform(); ShapeIt it=shapes.begin(); it++; for (; it!=shapes.end(); it++){ string256 namebuffer; Scene->GenObjectName (OBJCLASS_SHAPE, namebuffer, Name); CEditShape* shape = (CEditShape*)Scene->GetOTool(ClassID)->CreateObject(0, namebuffer); switch (it->type){ case cfSphere:{ Fsphere T = it->data.sphere; M.transform_tiny(T.P); shape->PPosition= T.P; T.P.set (0,0,0); shape->add_sphere(T); }break; case cfBox:{ Fmatrix B = it->data.box; B.mulA_43 (M); shape->PPosition= B.c; B.c.set (0,0,0); shape->add_box (B); }break; default: THROW; } Scene->AppendObject (shape,false); shape->Select (true); } // erase shapes in base object it=shapes.begin(); it++; shapes.erase(it,shapes.end()); ComputeBounds(); Scene->UndoSave(); } }
void SpatialNode::ApplyScale(float delta) { ApplyScale(Vector3(delta, delta, delta)); }
void CDLRendererV1_2Rev::_apply(const float * inImg, float * outImg, long numPixels) const { #ifdef USE_SSE __m128 inScale, outScale, slopeRev, offsetRev, powerRev, saturationRev, pix; LoadRenderParams(m_inScale, m_outScale, m_renderParams, inScale, outScale, slopeRev, offsetRev, powerRev, saturationRev); float inAlpha = 1.0f; const float * in = inImg; float * out = outImg; for(long idx=0; idx<numPixels; ++idx) { pix = LoadPixel(in, inAlpha); ApplyInScale(pix, inScale); ApplyClamp<CLAMP>(pix); ApplySaturation(pix, saturationRev); ApplyPower<CLAMP>(pix, powerRev); ApplyOffset(pix, offsetRev); ApplySlope(pix, slopeRev); ApplyClamp<CLAMP>(pix); ApplyOutScale(pix, outScale); StorePixel(out, pix, inAlpha * m_alphaScale); in += 4; out += 4; } #else const float * in = inImg; float * out = outImg; for (long idx = 0; idx<numPixels; ++idx) { const float inAlpha = in[3]; // NB: 'in' and 'out' could be pointers to the same memory buffer. memcpy(out, in, 4 * sizeof(float)); ApplyScale(out, m_inScale); ApplyClamp<CLAMP>(out); ApplySaturation(out, m_renderParams.getSaturation()); ApplyPower<CLAMP>(out, m_renderParams.getPower()); ApplyOffset(out, m_renderParams.getOffset()); ApplySlope(out, m_renderParams.getSlope()); ApplyClamp<CLAMP>(out); ApplyScale(out, m_outScale); out[3] = inAlpha * m_alphaScale; in += 4; out += 4; } #endif }
void CDLRendererV1_2Fwd::_apply(const float * inImg, float * outImg, long numPixels) const { #ifdef USE_SSE __m128 inScale, outScale, slope, offset, power, saturation, pix; LoadRenderParams(m_inScale, m_outScale, m_renderParams, inScale, outScale, slope, offset, power, saturation); float inAlpha; // Combine scale and slope so that they can be applied at the same time __m128 inScaleSlope = _mm_mul_ps(slope, inScale); const float * in = inImg; float * out = outImg; for(long idx=0; idx<numPixels; ++idx) { pix = LoadPixel(in, inAlpha); // inScale is combined with slope ApplySlope(pix, inScaleSlope); ApplyOffset(pix, offset); ApplyPower<CLAMP>(pix, power); ApplySaturation(pix, saturation); ApplyClamp<CLAMP>(pix); ApplyOutScale(pix, outScale); StorePixel(out, pix, inAlpha * m_alphaScale); in += 4; out += 4; } #else const float * in = inImg; float * out = outImg; // Combine inScale and slope const float * slope = m_renderParams.getSlope(); float inScaleSlope[3] = {slope[0], slope[1], slope[2]}; ApplyScale(inScaleSlope, m_inScale); for (long idx = 0; idx<numPixels; ++idx) { const float inAlpha = in[3]; // NB: 'in' and 'out' could be pointers to the same memory buffer. memcpy(out, in, 4 * sizeof(float)); ApplySlope(out, inScaleSlope); ApplyOffset(out, m_renderParams.getOffset()); ApplyPower<CLAMP>(out, m_renderParams.getPower()); ApplySaturation(out, m_renderParams.getSaturation()); ApplyClamp<CLAMP>(out); ApplyScale(out, m_outScale); out[3] = inAlpha * m_alphaScale; in += 4; out += 4; } #endif }
Entity::Entity(glm::mat4 world, glm::vec3 scale) : toWorld(world), scale(scale), VBO(0), VAO(0), EBO(0), shader(nullptr) { ApplyScale(); CalculateNormalMatrix(); }
void aiPoints::cookSampleBody(Sample& sample) { auto& summary = getSummary(); auto& config = getConfig(); if (!summary.interpolate_points && !m_sample_index_changed) return; int point_count = (int)sample.m_points_sp->size(); if (m_sample_index_changed) { if (m_sort) { sample.m_sort_data.resize(point_count); for (int i = 0; i < point_count; ++i) { sample.m_sort_data[i].first = ((*sample.m_points_sp)[i] - getSortPosition()).length(); sample.m_sort_data[i].second = i; } #ifdef _WIN32 concurrency::parallel_sort #else std::sort #endif (sample.m_sort_data.begin(), sample.m_sort_data.end(), [](const std::pair<float, int>& a, const std::pair<float, int>& b) { return a.first > b.first; }); Remap(sample.m_points, sample.m_points_sp, sample.m_sort_data); if (summary.interpolate_points) Remap(sample.m_points2, sample.m_points_sp2, sample.m_sort_data); if (!summary.compute_velocities && sample.m_velocities_sp) Remap(sample.m_velocities, sample.m_velocities_sp, sample.m_sort_data); if (sample.m_ids_sp) Remap(sample.m_ids, sample.m_ids_sp, sample.m_sort_data); } else { Assign(sample.m_points, sample.m_points_sp, point_count); if (summary.interpolate_points) Assign(sample.m_points2, sample.m_points_sp2, point_count); if (!summary.compute_velocities && sample.m_velocities_sp) Assign(sample.m_velocities, sample.m_velocities_sp, point_count); if (sample.m_ids_sp) Assign(sample.m_ids, sample.m_ids_sp, point_count); } sample.m_points_ref = sample.m_points; auto& config = getConfig(); if (config.swap_handedness) { SwapHandedness(sample.m_points.data(), (int)sample.m_points.size()); SwapHandedness(sample.m_points2.data(), (int)sample.m_points2.size()); SwapHandedness(sample.m_velocities.data(), (int)sample.m_velocities.size()); } if (config.scale_factor != 1.0f) { ApplyScale(sample.m_points.data(), (int)sample.m_points.size(), config.scale_factor); ApplyScale(sample.m_points2.data(), (int)sample.m_points2.size(), config.scale_factor); ApplyScale(sample.m_velocities.data(), (int)sample.m_velocities.size(), config.scale_factor); } { abcV3 bbmin, bbmax; MinMax(bbmin, bbmax, sample.m_points.data(), (int)sample.m_points.size()); sample.m_bb_center = (bbmin + bbmax) * 0.5f; sample.m_bb_size = bbmax - bbmin; } } if (summary.interpolate_points) { if (summary.compute_velocities) sample.m_points_int.swap(sample.m_points_prev); sample.m_points_int.resize_discard(sample.m_points.size()); Lerp(sample.m_points_int.data(), sample.m_points.data(), sample.m_points2.data(), (int)sample.m_points.size(), m_current_time_offset); sample.m_points_ref = sample.m_points_int; if (summary.compute_velocities) { sample.m_velocities.resize_discard(sample.m_points.size()); if (sample.m_points_int.size() == sample.m_points_prev.size()) { GenerateVelocities(sample.m_velocities.data(), sample.m_points_int.data(), sample.m_points_prev.data(), (int)sample.m_points_int.size(), config.vertex_motion_scale); } else { sample.m_velocities.zeroclear(); } } } }