feat(web): harden continuous implementation handoff
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled

This commit is contained in:
mes123456
2026-08-29 07:17:09 +08:00
parent 43d0c437bb
commit 01d535b362
43 changed files with 2061 additions and 54 deletions

View File

@@ -1585,7 +1585,7 @@ EMSCRIPTEN_KEEPALIVE int web_engine_apply_command(const int handle,
type == "moveObjectToCollection" || type == "renameId" || type == "joinObjects" ||
type == "separateMeshFaces" || type == "applyObjectTransform" || type == "setObjectOrigin" ||
type == "setCurveControlPoints" || type == "setCurveHandle" || type == "setCurveTopology" || type == "setCurveSplines" || type == "setSurfaceTopology" || type == "setFontBody" ||
type == "setFontProperties" || type == "setFontAdvanced" || type == "importVFont" || type == "setFontLinks" || type == "setTextSource" || type == "setSoundProperties" || type == "setSpeakerProperties" || type == "setParticleSettings" || type == "setVolumeProperties" || type == "deleteNonMeshData" ||
type == "setFontProperties" || type == "setFontAdvanced" || type == "importVFont" || type == "setFontLinks" || type == "setTextSource" || type == "setSoundProperties" || type == "setSpeakerProperties" || type == "setParticleSettings" || type == "setTextureProperties" || type == "setVolumeProperties" || type == "deleteNonMeshData" ||
type == "setMetaballElements" || type == "createGreasePencilLayer" ||
type == "removeGreasePencilLayer" || type == "moveGreasePencilLayer" ||
type == "moveGreasePencilFrame" ||
@@ -2044,6 +2044,17 @@ EMSCRIPTEN_KEEPALIVE int web_engine_apply_command(const int handle,
applied = web_engine_blend_main_set_particle_settings(
engine->authoritative_main, command.value("dataId", "").c_str(), edit, main_error);
}
else if (type == "setTextureProperties") {
const json properties = command.value("properties", json::object());
WebTexturePropertiesEdit edit;
edit.noise_scale = properties.value("noiseScale", -1.0f);
edit.noise_depth = properties.value("noiseDepth", -1);
edit.intensity = properties.value("intensity", -1.0f);
edit.contrast = properties.value("contrast", -1.0f);
edit.saturation = properties.value("saturation", -1.0f);
applied = web_engine_blend_main_set_texture_properties(
engine->authoritative_main, command.value("dataId", "").c_str(), edit, main_error);
}
else if (type == "setVolumeProperties") {
WebVolumePropertiesEdit properties;
properties.source_path = command.value("sourcePath", "");

View File

@@ -78,6 +78,7 @@
#include "DNA_sound_types.h"
#include "DNA_speaker_types.h"
#include "DNA_text_types.h"
#include "DNA_texture_types.h"
#include "DNA_world_types.h"
#include "DNA_userdef_enums.h"
#include "DNA_vfont_types.h"
@@ -324,6 +325,14 @@ ParticleSettings *find_particle_settings(Main *main, const char *data_id)
return nullptr;
}
Tex *find_texture(Main *main, const char *data_id)
{
if (main == nullptr || data_id == nullptr || strncmp(data_id, "texture:", 8) != 0) return nullptr;
const std::string name(data_id + 8);
for (Tex &texture : main->textures) if (id_name(texture.id) == name) return &texture;
return nullptr;
}
Light *find_light(Main *main, const char *data_id)
{
if (main == nullptr || data_id == nullptr || strncmp(data_id, "light:", 6) != 0) return nullptr;
@@ -4138,6 +4147,32 @@ bool web_engine_blend_main_set_particle_settings(WebBlendMainState *state,
return true;
}
bool web_engine_blend_main_set_texture_properties(WebBlendMainState *state,
const char *data_id,
const WebTexturePropertiesEdit &properties,
std::string &error)
{
Tex *texture = find_texture(state != nullptr ? state->main : nullptr, data_id);
if (texture == nullptr || texture->id.lib != nullptr) {
error = "NON_MESH_DATA_UNSUPPORTED: Texture data-block was not found or is linked read-only";
return false;
}
if ((properties.noise_scale >= 0.0f && (!std::isfinite(properties.noise_scale) || properties.noise_scale > 1000000.0f)) ||
(properties.noise_depth >= 0 && properties.noise_depth > 30) ||
(properties.intensity >= 0.0f && (!std::isfinite(properties.intensity) || properties.intensity > 1000000.0f)) ||
(properties.contrast >= 0.0f && (!std::isfinite(properties.contrast) || properties.contrast > 1000000.0f)) ||
(properties.saturation >= 0.0f && (!std::isfinite(properties.saturation) || properties.saturation > 1000000.0f))) {
error = "NON_MESH_PROPERTY_INVALID: Texture properties are outside the bounded range";
return false;
}
if (properties.noise_scale >= 0.0f) texture->noisesize = properties.noise_scale;
if (properties.noise_depth >= 0) texture->noisedepth = short(properties.noise_depth);
if (properties.intensity >= 0.0f) texture->bright = properties.intensity;
if (properties.contrast >= 0.0f) texture->contrast = properties.contrast;
if (properties.saturation >= 0.0f) texture->saturation = properties.saturation;
return true;
}
bool web_engine_blend_main_set_volume_properties(WebBlendMainState *state,
const char *data_id,
const WebVolumePropertiesEdit &properties,

View File

@@ -112,6 +112,14 @@ struct WebParticleSettingsEdit {
float draw_size = -1.0f;
};
struct WebTexturePropertiesEdit {
float noise_scale = -1.0f;
int noise_depth = -1;
float intensity = -1.0f;
float contrast = -1.0f;
float saturation = -1.0f;
};
struct WebGreasePencilPointEdit {
std::array<float, 3> position = {0.0f, 0.0f, 0.0f};
float radius = 0.01f;
@@ -418,6 +426,10 @@ bool web_engine_blend_main_set_particle_settings(WebBlendMainState *state,
const char *data_id,
const WebParticleSettingsEdit &properties,
std::string &error);
bool web_engine_blend_main_set_texture_properties(WebBlendMainState *state,
const char *data_id,
const WebTexturePropertiesEdit &properties,
std::string &error);
bool web_engine_blend_main_set_volume_properties(WebBlendMainState *state,
const char *data_id,
const WebVolumePropertiesEdit &properties,