KX_LodManager::KX_LodManager(Object *ob, KX_Scene* scene, KX_BlenderSceneConverter* converter, bool libloading) :m_refcount(1), m_distanceFactor(1.0f) { if (BLI_listbase_count_ex(&ob->lodlevels, 2) > 1) { Mesh *lodmesh = (Mesh *)ob->data; Object *lodmatob = ob; unsigned short level = 0; for (LodLevel *lod = (LodLevel *)ob->lodlevels.first; lod; lod = lod->next) { if (!lod->source || lod->source->type != OB_MESH) { continue; } unsigned short flag = 0; if (lod->flags & OB_LOD_USE_HYST) { flag |= KX_LodLevel::USE_HYSTERESIS; } if (lod->flags & OB_LOD_USE_MESH) { lodmesh = (Mesh*)lod->source->data; flag |= KX_LodLevel::USE_MESH; } if (lod->flags & OB_LOD_USE_MAT) { lodmatob = lod->source; flag |= KX_LodLevel::USE_MATERIAL; } KX_LodLevel *lodLevel = new KX_LodLevel(lod->distance, lod->obhysteresis, level++, BL_ConvertMesh(lodmesh, lodmatob, scene, converter, libloading), flag); m_levels.push_back(lodLevel); } } }
void render_result_views_new(RenderResult *rr, RenderData *rd) { SceneRenderView *srv; /* clear previously existing views - for sequencer */ render_result_views_free(rr); /* check renderdata for amount of views */ if ((rd->scemode & R_MULTIVIEW)) { for (srv = rd->views.first; srv; srv = srv->next) { if (BKE_scene_multiview_is_render_view_active(rd, srv) == false) continue; render_result_view_new(rr, srv->name); } } /* we always need at least one view */ if (BLI_listbase_count_ex(&rr->views, 1) == 0) { render_result_view_new(rr, ""); } }
void buttons_texture_context_compute(const bContext *C, SpaceButs *sbuts) { /* gather available texture users in context. runs on every draw of * properties editor, before the buttons are created. */ ButsContextTexture *ct = sbuts->texuser; Scene *scene = CTX_data_scene(C); ID *pinid = sbuts->pinid; set_texture_context(C, sbuts); if (!((sbuts->texture_context == SB_TEXC_OTHER) || BKE_scene_use_new_shading_nodes(scene))) { if (ct) { BLI_freelistN(&ct->users); MEM_freeN(ct); sbuts->texuser = NULL; } return; } if (!ct) { ct = MEM_callocN(sizeof(ButsContextTexture), "ButsContextTexture"); sbuts->texuser = ct; } else { BLI_freelistN(&ct->users); } buttons_texture_users_from_context(&ct->users, C, sbuts); if (pinid && GS(pinid->name) == ID_TE) { ct->user = NULL; ct->texture = (Tex *)pinid; } else { /* set one user as active based on active index */ if (ct->index == BLI_listbase_count_ex(&ct->users, ct->index + 1)) ct->index = 0; ct->user = BLI_findlink(&ct->users, ct->index); ct->texture = NULL; if (ct->user) { if (ct->user->ptr.data) { PointerRNA texptr; Tex *tex; /* get texture datablock pointer if it's a property */ texptr = RNA_property_pointer_get(&ct->user->ptr, ct->user->prop); tex = (RNA_struct_is_a(texptr.type, &RNA_Texture)) ? texptr.data : NULL; ct->texture = tex; } else if (ct->user->node && !(ct->user->node->flag & NODE_ACTIVE_TEXTURE)) { ButsTextureUser *user; /* detect change of active texture node in same node tree, in that * case we also automatically switch to the other node */ for (user = ct->users.first; user; user = user->next) { if (user->ntree == ct->user->ntree && user->node != ct->user->node) { if (user->node->flag & NODE_ACTIVE_TEXTURE) { ct->user = user; ct->index = BLI_findindex(&ct->users, user); break; } } } } } } }
void ImageNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const { /// Image output NodeOutput *outputImage = this->getOutputSocket(0); bNode *editorNode = this->getbNode(); Image *image = (Image *)editorNode->id; ImageUser *imageuser = (ImageUser *)editorNode->storage; int framenumber = context.getFramenumber(); int numberOfOutputs = this->getNumberOfOutputSockets(); bool outputStraightAlpha = (editorNode->custom1 & CMP_NODE_IMAGE_USE_STRAIGHT_OUTPUT) != 0; BKE_image_user_frame_calc(imageuser, context.getFramenumber(), 0); /* force a load, we assume iuser index will be set OK anyway */ if (image && image->type == IMA_TYPE_MULTILAYER) { bool is_multilayer_ok = false; ImBuf *ibuf = BKE_image_acquire_ibuf(image, imageuser, NULL); if (image->rr) { RenderLayer *rl = (RenderLayer *)BLI_findlink(&image->rr->layers, imageuser->layer); if (rl) { NodeOutput *socket; int index; is_multilayer_ok = true; for (index = 0; index < numberOfOutputs; index++) { NodeOperation *operation = NULL; socket = this->getOutputSocket(index); bNodeSocket *bnodeSocket = socket->getbNodeSocket(); RenderPass *rpass = (RenderPass *)BLI_findstring(&rl->passes, bnodeSocket->identifier, offsetof(RenderPass, internal_name)); int view = 0; /* Passes in the file can differ from passes stored in sockets (#36755). * Look up the correct file pass using the socket identifier instead. */ #if 0 NodeImageLayer *storage = (NodeImageLayer *)bnodeSocket->storage;*/ int passindex = storage->pass_index;*/ RenderPass *rpass = (RenderPass *)BLI_findlink(&rl->passes, passindex); #endif /* returns the image view to use for the current active view */ if (BLI_listbase_count_ex(&image->rr->views, 2) > 1) { const int view_image = imageuser->view; const bool is_allview = (view_image == 0); /* if view selected == All (0) */ if (is_allview) { /* heuristic to match image name with scene names * check if the view name exists in the image */ view = BLI_findstringindex(&image->rr->views, context.getViewName(), offsetof(RenderView, name)); if (view == -1) view = 0; } else { view = view_image - 1; } } if (rpass) { switch (rpass->channels) { case 1: operation = doMultilayerCheck(converter, rl, image, imageuser, framenumber, index, rpass->passtype, view, COM_DT_VALUE); break; /* using image operations for both 3 and 4 channels (RGB and RGBA respectively) */ /* XXX any way to detect actual vector images? */ case 3: operation = doMultilayerCheck(converter, rl, image, imageuser, framenumber, index, rpass->passtype, view, COM_DT_VECTOR); break; case 4: operation = doMultilayerCheck(converter, rl, image, imageuser, framenumber, index, rpass->passtype, view, COM_DT_COLOR); break; default: /* dummy operation is added below */ break; } if (index == 0 && operation) { converter.addPreview(operation->getOutputSocket()); } if (rpass->passtype == SCE_PASS_COMBINED) { BLI_assert(operation != NULL); BLI_assert(index < numberOfOutputs - 1); NodeOutput *outputSocket = this->getOutputSocket(index + 1); SeparateChannelOperation *separate_operation; separate_operation = new SeparateChannelOperation(); separate_operation->setChannel(3); converter.addOperation(separate_operation); converter.addLink(operation->getOutputSocket(), separate_operation->getInputSocket(0)); converter.mapOutputSocket(outputSocket, separate_operation->getOutputSocket()); index++; } } /* incase we can't load the layer */ if (operation == NULL) converter.setInvalidOutput(getOutputSocket(index)); } } }