/* public */ double LengthIndexedLine::clampIndex(double index) const { double posIndex = positiveIndex(index); double startIndex = getStartIndex(); if (posIndex < startIndex) return startIndex; double endIndex = getEndIndex(); if (posIndex > endIndex) return endIndex; return posIndex; }
XObjectPtr FunctionSubstring::execute( XPathExecutionContext& executionContext, XalanNode* /* context */, const XObjectPtr arg1, const XObjectPtr arg2, const XObjectPtr arg3, const LocatorType* /* locator */) const { assert(arg1.null() == false && arg2.null() == false); const XalanDOMString& theSourceString = arg1->str(); const XalanDOMString::size_type theSourceStringLength = length(theSourceString); if (theSourceStringLength == 0) { return createEmptyString(executionContext); } else { // Get the value of the second argument... const double theSecondArgValue = DoubleSupport::round(arg2->num()); // XPath indexes from 1, so this is the first XPath index.... const XalanDOMString::size_type theStartIndex = getStartIndex(theSecondArgValue, theSourceStringLength); if (theStartIndex >= theSourceStringLength) { return createEmptyString(executionContext); } else { const double theTotal = getTotal(theSourceStringLength, theSecondArgValue, arg3); if (DoubleSupport::isNaN(theSecondArgValue) == true || DoubleSupport::isNaN(theTotal) == true || DoubleSupport::isNegativeInfinity(theTotal) == true || theTotal == 0.0 || theTotal < double(theStartIndex)) { return createEmptyString(executionContext); } else { const XalanDOMString::size_type theSubstringLength = getSubstringLength( theSourceStringLength, theStartIndex, theTotal); XPathExecutionContext::GetAndReleaseCachedString theResult(executionContext); XalanDOMString& theString = theResult.get(); assign( theString, toCharArray(theSourceString) + theStartIndex, theSubstringLength); return executionContext.getXObjectFactory().createString(theResult); } } } }
bool LengthIndexedLine::isValidIndex(double index) const { return (index >= getStartIndex() && index <= getEndIndex()); }
void CreatureCore::UpdateCreatureRender() { SCOPE_CYCLE_COUNTER(STAT_CreatureCore_UpdateCreatureRender); auto cur_creature = creature_manager->GetCreature(); int num_triangles = cur_creature->GetTotalNumIndices() / 3; glm::uint32 * cur_idx = cur_creature->GetGlobalIndices(); auto cur_num_indices = cur_creature->GetTotalNumIndices(); glm::float32 * cur_pts = cur_creature->GetRenderPts(); glm::float32 * cur_uvs = cur_creature->GetGlobalUvs(); should_update_render_indices = false; // Update depth per region std::vector<meshRenderRegion *>& cur_regions = cur_creature->GetRenderComposition()->getRegions(); float region_z = 0.0f, delta_z = region_overlap_z_delta; if (region_custom_order.Num() != cur_regions.size()) { // Normal update in default order for (auto& single_region : cur_regions) { glm::float32 * region_pts = cur_pts + (single_region->getStartPtIndex() * 3); for (size_t i = 0; i < single_region->getNumPts(); i++) { region_pts[2] = region_z; region_pts += 3; } region_z += delta_z; } } else { // Custom order update auto& regions_map = cur_creature->GetRenderComposition()->getRegionsMap(); int32 indice_idx = 0; auto dst_indices = GetIndicesCopy(cur_num_indices); for (auto& custom_region_name : region_custom_order) { auto real_name = ConvertToString(custom_region_name); if (regions_map.count(real_name) > 0) { auto single_region = regions_map[real_name]; glm::float32 * region_pts = cur_pts + (single_region->getStartPtIndex() * 3); for (size_t i = 0; i < single_region->getNumPts(); i++) { region_pts[2] = region_z; region_pts += 3; } region_z += delta_z; // Reorder indices auto copy_start_idx = single_region->getStartIndex(); auto copy_end_idx = single_region->getEndIndex(); auto copy_num_indices = copy_end_idx - copy_start_idx + 1; FMemory::Memcpy(dst_indices + indice_idx, cur_idx + copy_start_idx, sizeof(glm::uint32) * copy_num_indices); indice_idx += copy_num_indices; } } should_update_render_indices = true; } // Build render triangles /* TArray<FProceduralMeshTriangle>& write_triangles = draw_tris; static const FColor White(255, 255, 255, 255); int cur_pt_idx = 0, cur_uv_idx = 0; const int x_id = 0; const int y_id = 2; const int z_id = 1; for (int i = 0; i < num_triangles; i++) { int real_idx_1 = cur_idx[0]; int real_idx_2 = cur_idx[1]; int real_idx_3 = cur_idx[2]; FProceduralMeshTriangle triangle; cur_pt_idx = real_idx_1 * 3; cur_uv_idx = real_idx_1 * 2; triangle.Vertex0.Position.Set(cur_pts[cur_pt_idx + x_id], cur_pts[cur_pt_idx + y_id], cur_pts[cur_pt_idx + z_id]); triangle.Vertex0.Color = White; triangle.Vertex0.U = cur_uvs[cur_uv_idx]; triangle.Vertex0.V = cur_uvs[cur_uv_idx + 1]; cur_pt_idx = real_idx_2 * 3; cur_uv_idx = real_idx_2 * 2; triangle.Vertex1.Position.Set(cur_pts[cur_pt_idx + x_id], cur_pts[cur_pt_idx + y_id], cur_pts[cur_pt_idx + z_id]); triangle.Vertex1.Color = White; triangle.Vertex1.U = cur_uvs[cur_uv_idx]; triangle.Vertex1.V = cur_uvs[cur_uv_idx + 1]; cur_pt_idx = real_idx_3 * 3; cur_uv_idx = real_idx_3 * 2; triangle.Vertex2.Position.Set(cur_pts[cur_pt_idx + x_id], cur_pts[cur_pt_idx + y_id], cur_pts[cur_pt_idx + z_id]); triangle.Vertex2.Color = White; triangle.Vertex2.U = cur_uvs[cur_uv_idx]; triangle.Vertex2.V = cur_uvs[cur_uv_idx + 1]; write_triangles[i] = triangle; cur_idx += 3; } */ // process the render regions ProcessRenderRegions(); }