This commit is contained in:
laodaming 2023-11-27 11:46:04 +08:00
parent 209073d08a
commit 6f1ced3bf8

View File

@ -281,15 +281,8 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe
taskId := w.genRenderTaskId(combineImage, renderImageData, model3dInfo, productTemplate, element)
//查询有没有缓存的资源,有就返回
resource, err := w.logic.svcCtx.AllModels.FsResource.FindOneById(w.logic.ctx, taskId)
if err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) {
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, taskId, "获取unity云渲染缓存失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productSize.Id, *productTemplate.ElementModelId)
logx.Error("failed to find render resource:", err)
return
}
//无缓存
logx.Info("无缓存的渲染图需要unity")
} else { //有缓存
switch err {
case nil: //有缓存
//如果没有debug或者debug模式下开启了缓存则返回缓存
if w.debug == nil || w.debug.IsCache == 1 {
//返回给客户端
@ -305,6 +298,12 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe
return
}
//否则继续去unity
default: //无缓存
if !errors.Is(err, gorm.ErrRecordNotFound) {
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, taskId, "获取unity云渲染缓存失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productSize.Id, *productTemplate.ElementModelId)
logx.Error("failed to find render resource:", err)
return
}
}
//组装数据
if err = w.assembleRenderDataToUnity(taskId, resolution, combineImage, renderImageData, productTemplate, model3dInfo, element, productSize); err != nil {