ads-game:: better ship shape handling

This commit is contained in:
Zeno Rogue 2022-09-29 01:39:16 +02:00
parent bcd6d772f6
commit 49ce0c1551
3 changed files with 19 additions and 12 deletions

View File

@ -223,8 +223,6 @@ void view_ads_game() {
);
if(1) {
make_shape();
set<cell*> visited;
std::priority_queue<cell_to_draw> dq;
auto visit = [&] (cell *c, const ads_matrix& V) {
@ -278,7 +276,7 @@ void view_ads_game() {
ld u = (invincibility_pt-ship_pt) / ads_how_much_invincibility;
poly_outline = gradient(shipcolor, rsrc_color[rtHull], 0, 0.5 + cos(5*u*TAU), 1);
}
queuepolyat(shiftless(spin(ang*degree) * Id), shShip, shipcolor, PPR::MONSTER_HAIR);
queuepolyat(shiftless(spin(ang*degree) * Id), make_shape(), shipcolor, PPR::MONSTER_HAIR);
poly_outline = 0xFF;
if(view_proper_times) {

View File

@ -453,8 +453,6 @@ void view_ds_game() {
draw_textures();
if(1) {
make_shape();
for(auto& r: rocks) {
auto& rock = *r;
poly_outline = 0xFF;
@ -543,7 +541,7 @@ void view_ds_game() {
ld u = (invincibility_pt-ship_pt) / ds_how_much_invincibility;
poly_outline = gradient(shipcolor, rsrc_color[rtHull], 0, 0.5 + cos(5*u*TAU), 1);
}
queuepolyat(shiftless(spin(ang*degree) * Id), shShip, shipcolor, PPR::MONSTER_HAIR);
queuepolyat(shiftless(spin(ang*degree)), make_shape(), shipcolor, PPR::MONSTER_HAIR);
poly_outline = 0xFF;
if(view_proper_times) {

View File

@ -2,9 +2,6 @@ namespace hr {
namespace ads_game {
hpcshape shShip;
ld made_scale = -1;
vector<ld> shape_rock = { -0.0176894, 0.0952504, 0.0278998, 0.0966286, 0.0686721, 0.0455547, 0.110983, 0.0122558, 0.0994024, -0.0483395, 0.0517039, -0.0802772, -0.00271848, -0.0706804, -0.0564861, -0.08575, -0.100087, -0.0483411, -0.100031, -0.0102072, -0.0761486, 0.0292356, -0.0639653, 0.077575 };
vector<ld> shape_rock2 = {-0.00204264, 0.111665, 0.0374777, 0.119247, 0.0797168, 0.0940249, 0.106214, 0.0326813, 0.121954, -0.0109009, 0.0837905, -0.0865154, 0.0517718, -0.108312, 0.00135972, -0.0802237, -0.0632991, -0.0837181, -0.0980407, -0.0510629, -0.122639, 0.00885725, -0.0817448, 0.0878757, };
vector<ld> shape_missile = { 0.04, 0, 0.01, -0.02, -0.02, -0.02, -0.02, 0.02, 0.01, 0.02, };
@ -16,10 +13,22 @@ vector<ld> shape_fuel = {0.0802337, 0.0224383, 0.0802337, -0.0224383, 0.0224383,
vector<ld> shape_airtank = {-0.101054, 0.0134738, -0.0904219, 0.014429, -0.0779099, 0.0442451, 0.078873, 0.043284, 0.0894665, 0.0259742, 0.0894665, -0.0259742, 0.078873, -0.043284, -0.0779099, -0.0442451, -0.0904219, -0.014429, -0.101054, -0.0134738, };
vector<ld> shape_ship = { 0.0699706, 0, 0.0509304, 0.019032, 0.0056909, 0.023788, 0.0318813, 0.0309258, 0.0330715, 0.0368693, 0.00331668, 0.0380512, -0.0630665, 0.0699568, -0.0619577, 0.041535, -0.0678691, 0.0415233, -0.0678946, 0.0261072, -0.0572505, 0.0237463, -0.0572505, -0.0237463, -0.0678946, -0.0261072, -0.0678691, -0.0415233, -0.0619577, -0.041535, -0.0630665, -0.0699568, 0.00331668, -0.0380512, 0.0330715, -0.0368693, 0.0318813, -0.0309258, 0.0056909, -0.023788, 0.0509304, -0.019032 };
void make_shape() {
struct ship_model: gi_extension {
map<ld, hpcshape> ship_at_scale;
};
const hpcshape& make_shape() {
auto& mmd = (unique_ptr<ship_model>&) cgi.ext["ship_model"];
if(!mmd) mmd = std::make_unique<ship_model> ();
auto scale = DS_(scale);
if(made_scale == scale) return;
made_scale = scale;
auto sas = at_or_null(mmd->ship_at_scale, scale);
if(sas) return *sas;
auto& shShip = mmd->ship_at_scale[scale];
cgi.bshape(shShip, PPR::MONSTER_BODY);
int N = isize(shape_ship);
@ -29,6 +38,8 @@ void make_shape() {
cgi.hpcpush(lst[0]);
cgi.finishshape();
cgi.extra_vertices();
return shShip;
}
}}