Skip to content

Commit

Permalink
atlas-packerに合わせた構造変更(3dtilesのみ)
Browse files Browse the repository at this point in the history
  • Loading branch information
TadaTeruki committed Sep 21, 2024
1 parent fa31e4b commit 7f9420f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
13 changes: 8 additions & 5 deletions nusamai/src/sink/cesiumtiles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ use atlas_packer::{
export::{AtlasExporter as _, JpegAtlasExporter},
pack::AtlasPacker,
place::{GuillotineTexturePlacer, TexturePlacerConfig},
texture::{CroppedTexture, DownsampleFactor, TextureCache, TextureSizeCache},
texture::{
cache::{TextureCache, TextureSizeCache},
DownsampleFactor, PolygonMappedTexture,
},
};
use bytemuck::Zeroable;
use earcut::{utils3d::project3d_to_2d, Earcut};
Expand Down Expand Up @@ -411,8 +414,6 @@ fn tile_writing_stage(
padding: 0,
};

let exporter = JpegAtlasExporter::default();
let ext = exporter.clone().get_extension().to_string();
let packer = Mutex::new(AtlasPacker::default());

let features = {
Expand Down Expand Up @@ -519,7 +520,7 @@ fn tile_writing_stage(
let factor = apply_downsample_factor(tile_zoom, downsample_scale as f32);

let downsample_factor = DownsampleFactor::new(&factor);
let cropped_texture = CroppedTexture::new(
let cropped_texture = PolygonMappedTexture::new(
&texture_uri,
texture_size,
&uv_coords,
Expand All @@ -542,6 +543,9 @@ fn tile_writing_stage(
let packer = packer.into_inner().unwrap();
let packed = packer.pack(placer);

let exporter = JpegAtlasExporter::default();
let ext = exporter.clone().get_extension().to_string();

for (feature_id, feature) in features.iter().enumerate() {
for (poly_count, (mut mat, mut poly)) in feature
.polygons
Expand Down Expand Up @@ -656,7 +660,6 @@ fn tile_writing_stage(
let (z, x, y) = tile_id_conv.id_to_zxy(tile_id);
let atlas_path = atlas_dir.join(format!("{}/{}/{}", z, x, y));
fs::create_dir_all(&atlas_path)?;

packed.export(
exporter,
&atlas_path,
Expand Down
6 changes: 1 addition & 5 deletions nusamai/src/sink/gltf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ use std::{f64::consts::FRAC_PI_2, fs::File, io::BufWriter, path::PathBuf, sync::

use crate::sink::cesiumtiles::utils::calculate_normal;
use ahash::{HashMap, HashSet, RandomState};
use atlas_packer::{
export::{AtlasExporter as _, JpegAtlasExporter},
place::{GuillotineTexturePlacer, PlacedTextureInfo, TexturePlacerConfig},
texture::{CroppedTexture, DownsampleFactor, TextureCache, TextureSizeCache},
};
use atlas_packer::export::{AtlasExporter as _, JpegAtlasExporter};
use earcut::{utils3d::project3d_to_2d, Earcut};
use flatgeom::MultiPolygon;
use glam::{DMat4, DVec3, DVec4};
Expand Down
1 change: 0 additions & 1 deletion nusamai/src/sink/obj/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use ahash::{HashMap, HashMapExt};
use atlas_packer::{
export::{AtlasExporter as _, JpegAtlasExporter},
place::{GuillotineTexturePlacer, TexturePlacerConfig},
texture::{CroppedTexture, DownsampleFactor, TextureCache, TextureSizeCache},
};
use earcut::{utils3d::project3d_to_2d, Earcut};
use flatgeom::MultiPolygon;
Expand Down

0 comments on commit 7f9420f

Please sign in to comment.