diff options
105 files changed, 835 insertions, 621 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index bd038415772..191fb61e1b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,3 @@ -set(Boost_DEBUG TRUE) # ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or diff --git a/intern/container/CTR_UHeap.h b/intern/container/CTR_UHeap.h index ad3d7d2bb02..8711d4375cb 100644 --- a/intern/container/CTR_UHeap.h +++ b/intern/container/CTR_UHeap.h @@ -56,7 +56,7 @@ class CTR_UHeapable { public : int & HeapPos( - ){ + ) { return m_ind; }; float & @@ -93,7 +93,7 @@ protected : }; ~CTR_UHeapable( - ){ + ) { }; }; @@ -214,7 +214,7 @@ private: HeapType *base, int i, int j - ){ + ) { std::swap(m_vector[i],m_vector[j]); CTR_UHeapable *heap_i = base + m_vector[i]; diff --git a/intern/cycles/blender/blender_camera.cpp b/intern/cycles/blender/blender_camera.cpp index bdd02bb5086..9bc82344fcc 100644 --- a/intern/cycles/blender/blender_camera.cpp +++ b/intern/cycles/blender/blender_camera.cpp @@ -56,6 +56,11 @@ struct BlenderCamera { float sensor_width; float sensor_height; + float border_left; + float border_right; + float border_bottom; + float border_top; + Transform matrix; }; @@ -70,6 +75,8 @@ static void blender_camera_init(BlenderCamera *bcam) bcam->sensor_height = 18.0f; bcam->sensor_fit = BlenderCamera::AUTO; bcam->shuttertime = 1.0f; + bcam->border_right = 1.0f; + bcam->border_top = 1.0f; } static float blender_camera_focal_distance(BL::Object b_ob, BL::Camera b_camera) @@ -188,85 +195,94 @@ static Transform blender_camera_matrix(const Transform& tfm, CameraType type) return transform_clear_scale(result); } -static void blender_camera_sync(Camera *cam, BlenderCamera *bcam, int width, int height) +static void blender_camera_viewplane(BlenderCamera *bcam, int width, int height, + float *left, float *right, float *bottom, float *top, float *aspectratio, float *sensor_size) { - /* copy camera to compare later */ - Camera prevcam = *cam; - /* dimensions */ float xratio = width*bcam->pixelaspect.x; float yratio = height*bcam->pixelaspect.y; /* compute x/y aspect and ratio */ - float aspectratio, xaspect, yaspect; + float xaspect, yaspect; /* sensor fitting */ bool horizontal_fit; - float sensor_size; - - cam->sensorwidth = bcam->sensor_width; - cam->sensorheight = bcam->sensor_height; if(bcam->sensor_fit == BlenderCamera::AUTO) { horizontal_fit = (xratio > yratio); - sensor_size = bcam->sensor_width; + *sensor_size = bcam->sensor_width; } else if(bcam->sensor_fit == BlenderCamera::HORIZONTAL) { horizontal_fit = true; - sensor_size = bcam->sensor_width; + *sensor_size = bcam->sensor_width; } else { horizontal_fit = false; - sensor_size = bcam->sensor_height; + *sensor_size = bcam->sensor_height; } if(horizontal_fit) { - aspectratio= xratio/yratio; - xaspect= aspectratio; + *aspectratio= xratio/yratio; + xaspect= *aspectratio; yaspect= 1.0f; } else { - aspectratio= yratio/xratio; + *aspectratio= yratio/xratio; xaspect= 1.0f; - yaspect= aspectratio; + yaspect= *aspectratio; } /* modify aspect for orthographic scale */ if(bcam->type == CAMERA_ORTHOGRAPHIC) { - xaspect = xaspect*bcam->ortho_scale/(aspectratio*2.0f); - yaspect = yaspect*bcam->ortho_scale/(aspectratio*2.0f); - aspectratio = bcam->ortho_scale/2.0f; + xaspect = xaspect*bcam->ortho_scale/(*aspectratio*2.0f); + yaspect = yaspect*bcam->ortho_scale/(*aspectratio*2.0f); + *aspectratio = bcam->ortho_scale/2.0f; } if(bcam->type == CAMERA_PANORAMA) { /* set viewplane */ - cam->left = 0.0f; - cam->right = 1.0f; - cam->bottom = 0.0f; - cam->top = 1.0f; + *left = 0.0f; + *right = 1.0f; + *bottom = 0.0f; + *top = 1.0f; } else { /* set viewplane */ - cam->left = -xaspect; - cam->right = xaspect; - cam->bottom = -yaspect; - cam->top = yaspect; + *left = -xaspect; + *right = xaspect; + *bottom = -yaspect; + *top = yaspect; /* zoom for 3d camera view */ - cam->left *= bcam->zoom; - cam->right *= bcam->zoom; - cam->bottom *= bcam->zoom; - cam->top *= bcam->zoom; + *left *= bcam->zoom; + *right *= bcam->zoom; + *bottom *= bcam->zoom; + *top *= bcam->zoom; /* modify viewplane with camera shift and 3d camera view offset */ - float dx = 2.0f*(aspectratio*bcam->shift.x + bcam->offset.x*xaspect*2.0f); - float dy = 2.0f*(aspectratio*bcam->shift.y + bcam->offset.y*yaspect*2.0f); + float dx = 2.0f*(*aspectratio*bcam->shift.x + bcam->offset.x*xaspect*2.0f); + float dy = 2.0f*(*aspectratio*bcam->shift.y + bcam->offset.y*yaspect*2.0f); - cam->left += dx; - cam->right += dx; - cam->bottom += dy; - cam->top += dy; + *left += dx; + *right += dx; + *bottom += dy; + *top += dy; } +} + +static void blender_camera_sync(Camera *cam, BlenderCamera *bcam, int width, int height) +{ + /* copy camera to compare later */ + Camera prevcam = *cam; + float aspectratio, sensor_size; + + /* viewplane */ + blender_camera_viewplane(bcam, width, height, + &cam->left, &cam->right, &cam->bottom, &cam->top, &aspectratio, &sensor_size); + + /* sensor */ + cam->sensorwidth = bcam->sensor_width; + cam->sensorheight = bcam->sensor_height; /* clipping distances */ cam->nearclip = bcam->nearclip; @@ -294,6 +310,12 @@ static void blender_camera_sync(Camera *cam, BlenderCamera *bcam, int width, int cam->use_motion = false; cam->shuttertime = bcam->shuttertime; + /* border */ + cam->border_left = bcam->border_left; + cam->border_right = bcam->border_right; + cam->border_bottom = bcam->border_bottom; + cam->border_top = bcam->border_top; + /* set update flag */ if(cam->modified(prevcam)) cam->tag_update(); @@ -313,6 +335,14 @@ void BlenderSync::sync_camera(BL::Object b_override, int width, int height) bcam.pixelaspect.y = r.pixel_aspect_y(); bcam.shuttertime = r.motion_blur_shutter(); + /* border */ + if(r.use_border()) { + bcam.border_left = r.border_min_x(); + bcam.border_right = r.border_max_x(); + bcam.border_bottom = r.border_min_y(); + bcam.border_top = r.border_max_y(); + } + /* camera object */ BL::Object b_ob = b_scene.camera(); @@ -348,67 +378,142 @@ void BlenderSync::sync_camera_motion(BL::Object b_ob, int motion) /* Sync 3D View Camera */ -void BlenderSync::sync_view(BL::SpaceView3D b_v3d, BL::RegionView3D b_rv3d, int width, int height) +static void blender_camera_from_view(BlenderCamera *bcam, BL::Scene b_scene, BL::SpaceView3D b_v3d, BL::RegionView3D b_rv3d, int width, int height) { - BlenderCamera bcam; - blender_camera_init(&bcam); - /* 3d view parameters */ - bcam.nearclip = b_v3d.clip_start(); - bcam.farclip = b_v3d.clip_end(); - bcam.lens = b_v3d.lens(); - bcam.shuttertime = b_scene.render().motion_blur_shutter(); + bcam->nearclip = b_v3d.clip_start(); + bcam->farclip = b_v3d.clip_end(); + bcam->lens = b_v3d.lens(); + bcam->shuttertime = b_scene.render().motion_blur_shutter(); if(b_rv3d.view_perspective() == BL::RegionView3D::view_perspective_CAMERA) { /* camera view */ BL::Object b_ob = (b_v3d.lock_camera_and_layers())? b_scene.camera(): b_v3d.camera(); if(b_ob) { - blender_camera_from_object(&bcam, b_ob); + blender_camera_from_object(bcam, b_ob); /* magic zoom formula */ - bcam.zoom = (float)b_rv3d.view_camera_zoom(); - bcam.zoom = (1.41421f + bcam.zoom/50.0f); - bcam.zoom *= bcam.zoom; - bcam.zoom = 2.0f/bcam.zoom; + bcam->zoom = (float)b_rv3d.view_camera_zoom(); + bcam->zoom = (1.41421f + bcam->zoom/50.0f); + bcam->zoom *= bcam->zoom; + bcam->zoom = 2.0f/bcam->zoom; /* offset */ - bcam.offset = get_float2(b_rv3d.view_camera_offset()); + bcam->offset = get_float2(b_rv3d.view_camera_offset()); } } else if(b_rv3d.view_perspective() == BL::RegionView3D::view_perspective_ORTHO) { /* orthographic view */ - bcam.farclip *= 0.5; - bcam.nearclip = -bcam.farclip; + bcam->farclip *= 0.5; + bcam->nearclip = -bcam->farclip; - bcam.type = CAMERA_ORTHOGRAPHIC; - bcam.ortho_scale = b_rv3d.view_distance(); + bcam->type = CAMERA_ORTHOGRAPHIC; + bcam->ortho_scale = b_rv3d.view_distance(); } - bcam.zoom *= 2.0f; + bcam->zoom *= 2.0f; /* 3d view transform */ - bcam.matrix = transform_inverse(get_transform(b_rv3d.view_matrix())); + bcam->matrix = transform_inverse(get_transform(b_rv3d.view_matrix())); +} + +static void blender_camera_border(BlenderCamera *bcam, BL::Scene b_scene, BL::SpaceView3D b_v3d, + BL::RegionView3D b_rv3d, int width, int height) +{ + BL::RenderSettings r = b_scene.render(); + + if(!r.use_border()) + return; + + /* camera view? */ + if(!(b_rv3d && b_rv3d.view_perspective() == BL::RegionView3D::view_perspective_CAMERA)) + return; + + BL::Object b_ob = (b_v3d.lock_camera_and_layers())? b_scene.camera(): b_v3d.camera(); + + if(!b_ob) + return; + + bcam->border_left = r.border_min_x(); + bcam->border_right = r.border_max_x(); + bcam->border_bottom = r.border_min_y(); + bcam->border_top = r.border_max_y(); + + float cam_left, cam_right, cam_bottom, cam_top; + float view_left, view_right, view_bottom, view_top; + float view_aspect, cam_aspect, sensor_size; + + /* get viewport viewplane */ + BlenderCamera view_bcam; + blender_camera_init(&view_bcam); + blender_camera_from_view(&view_bcam, b_scene, b_v3d, b_rv3d, width, height); + + blender_camera_viewplane(&view_bcam, width, height, + &view_left, &view_right, &view_bottom, &view_top, &view_aspect, &sensor_size); + + view_left /= view_aspect; + view_right /= view_aspect; + view_bottom /= view_aspect; + view_top /= view_aspect; + + /* get camera viewplane */ + BlenderCamera cam_bcam; + blender_camera_init(&cam_bcam); + blender_camera_from_object(&cam_bcam, b_ob); + + width = (int)(r.resolution_x()*r.resolution_percentage()/100); + height = (int)(r.resolution_y()*r.resolution_percentage()/100); + + blender_camera_viewplane(&cam_bcam, width, height, + &cam_left, &cam_right, &cam_bottom, &cam_top, &cam_aspect, &sensor_size); + + cam_left /= cam_aspect; + cam_right /= cam_aspect; + cam_bottom /= cam_aspect; + cam_top /= cam_aspect; + + /* determine viewport subset matching camera border */ + float tmp_left = ((cam_left - view_left) / (view_right - view_left)); + float tmp_right = ((cam_right - view_left) / (view_right - view_left)); + float tmp_bottom = ((cam_bottom - view_bottom) / (view_top - view_bottom)); + float tmp_top = ((cam_top - view_bottom) / (view_top - view_bottom)); + + bcam->border_left = tmp_left + bcam->border_left*(tmp_right - tmp_left); + bcam->border_right = tmp_left + bcam->border_right*(tmp_right - tmp_left); + bcam->border_bottom = tmp_bottom + bcam->border_bottom*(tmp_top - tmp_bottom); + bcam->border_top = tmp_bottom + bcam->border_top*(tmp_top - tmp_bottom); + + /* clamp */ + bcam->border_left = max(bcam->border_left, 0.0f); + bcam->border_right = min(bcam->border_right, 1.0f); + bcam->border_bottom = max(bcam->border_bottom, 0.0f); + bcam->border_top = min(bcam->border_top, 1.0f); +} + +void BlenderSync::sync_view(BL::SpaceView3D b_v3d, BL::RegionView3D b_rv3d, int width, int height) +{ + BlenderCamera bcam; + blender_camera_init(&bcam); + blender_camera_from_view(&bcam, b_scene, b_v3d, b_rv3d, width, height); + blender_camera_border(&bcam, b_scene, b_v3d, b_rv3d, width, height); - /* sync */ blender_camera_sync(scene->camera, &bcam, width, height); } -BufferParams BlenderSync::get_buffer_params(BL::Scene b_scene, BL::RegionView3D b_rv3d, int width, int height) +BufferParams BlenderSync::get_buffer_params(BL::Scene b_scene, Camera *cam, int width, int height) { BufferParams params; params.full_width = width; params.full_height = height; - /* border render */ - BL::RenderSettings r = b_scene.render(); - - if(!b_rv3d && r.use_border()) { - params.full_x = r.border_min_x()*width; - params.full_y = r.border_min_y()*height; - params.width = (int)(r.border_max_x()*width) - params.full_x; - params.height = (int)(r.border_max_y()*height) - params.full_y; + if(b_scene.render().use_border()) { + /* border render */ + params.full_x = cam->border_left*width; + params.full_y = cam->border_bottom*height; + params.width = (int)(cam->border_right*width) - params.full_x; + params.height = (int)(cam->border_top*height) - params.full_y; } else { params.width = width; diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp index 997909f1b92..9726f7b94cf 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -106,7 +106,7 @@ void BlenderSession::create_session() session->set_pause(BlenderSync::get_session_pause(b_scene, background)); /* set buffer parameters */ - BufferParams buffer_params = BlenderSync::get_buffer_params(b_scene, b_rv3d, width, height); + BufferParams buffer_params = BlenderSync::get_buffer_params(b_scene, scene->camera, width, height); session->reset(buffer_params, session_params.samples); } @@ -181,7 +181,7 @@ void BlenderSession::render() { /* get buffer parameters */ SessionParams session_params = BlenderSync::get_session_params(b_userpref, b_scene, background); - BufferParams buffer_params = BlenderSync::get_buffer_params(b_scene, b_rv3d, width, height); + BufferParams buffer_params = BlenderSync::get_buffer_params(b_scene, scene->camera, width, height); int w = buffer_params.width, h = buffer_params.height; /* create render result */ @@ -326,7 +326,7 @@ void BlenderSession::synchronize() /* reset if needed */ if(scene->need_reset()) { - BufferParams buffer_params = BlenderSync::get_buffer_params(b_scene, b_rv3d, width, height); + BufferParams buffer_params = BlenderSync::get_buffer_params(b_scene, scene->camera, width, height); session->reset(buffer_params, session_params.samples); } } @@ -364,7 +364,7 @@ bool BlenderSession::draw(int w, int h) /* reset if requested */ if(reset) { SessionParams session_params = BlenderSync::get_session_params(b_userpref, b_scene, background); - BufferParams buffer_params = BlenderSync::get_buffer_params(b_scene, b_rv3d, width, height); + BufferParams buffer_params = BlenderSync::get_buffer_params(b_scene, scene->camera, w, h); session->reset(buffer_params, session_params.samples); } @@ -374,7 +374,7 @@ bool BlenderSession::draw(int w, int h) update_status_progress(); /* draw */ - BufferParams buffer_params = BlenderSync::get_buffer_params(b_scene, b_rv3d, width, height); + BufferParams buffer_params = BlenderSync::get_buffer_params(b_scene, scene->camera, width, height); return !session->draw(buffer_params); } diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h index 10afd468850..bc6258d35ac 100644 --- a/intern/cycles/blender/blender_sync.h +++ b/intern/cycles/blender/blender_sync.h @@ -63,7 +63,7 @@ public: static SceneParams get_scene_params(BL::Scene b_scene, bool background); static SessionParams get_session_params(BL::UserPreferences b_userpref, BL::Scene b_scene, bool background); static bool get_session_pause(BL::Scene b_scene, bool background); - static BufferParams get_buffer_params(BL::Scene b_scene, BL::RegionView3D b_rv3d, int width, int height); + static BufferParams get_buffer_params(BL::Scene b_scene, Camera *cam, int width, int height); private: /* sync */ diff --git a/intern/cycles/kernel/kernel_light.h b/intern/cycles/kernel/kernel_light.h index a056cd71bb1..2bc5a882ce5 100644 --- a/intern/cycles/kernel/kernel_light.h +++ b/intern/cycles/kernel/kernel_light.h @@ -391,6 +391,10 @@ __device float light_sample_pdf(KernelGlobals *kg, LightSample *ls, float3 I, fl __device void light_select(KernelGlobals *kg, int index, float randu, float randv, float3 P, LightSample *ls, float *pdf) { regular_light_sample(kg, index, randu, randv, P, ls, pdf); + + /* compute incoming direction and distance */ + if(ls->t != FLT_MAX) + ls->D = normalize_len(ls->P - P, &ls->t); } __device float light_select_pdf(KernelGlobals *kg, LightSample *ls, float3 I, float t) diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h index e0e17ee57dc..e41a5a62c14 100644 --- a/intern/cycles/kernel/kernel_path.h +++ b/intern/cycles/kernel/kernel_path.h @@ -365,7 +365,7 @@ __device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, R #ifdef __MULTI_LIGHT__ /* index -1 means randomly sample from distribution */ - int i = (kernel_data.integrator.num_distribution)? -1: 0; + int i = (kernel_data.integrator.num_all_lights)? 0: -1; for(; i < kernel_data.integrator.num_all_lights; i++) { #else diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp index a80851b945a..a7fd47c94cf 100644 --- a/intern/cycles/render/buffers.cpp +++ b/intern/cycles/render/buffers.cpp @@ -311,8 +311,14 @@ void DisplayBuffer::draw_set(int width, int height) void DisplayBuffer::draw(Device *device) { - if(draw_width != 0 && draw_height != 0) + if(draw_width != 0 && draw_height != 0) { + glPushMatrix(); + glTranslatef(params.full_x, params.full_y, 0.0f); + device->draw_pixels(rgba, 0, draw_width, draw_height, 0, params.width, params.height, transparent); + + glPopMatrix(); + } } bool DisplayBuffer::draw_ready() diff --git a/intern/cycles/render/camera.cpp b/intern/cycles/render/camera.cpp index 3ecffab7cbc..ed239074cd4 100644 --- a/intern/cycles/render/camera.cpp +++ b/intern/cycles/render/camera.cpp @@ -58,6 +58,11 @@ Camera::Camera() bottom = -1.0f; top = 1.0f; + border_left = 0.0f; + border_right = 1.0f; + border_bottom = 0.0f; + border_top = 1.0f; + screentoworld = transform_identity(); rastertoworld = transform_identity(); ndctoworld = transform_identity(); @@ -248,6 +253,10 @@ bool Camera::modified(const Camera& cam) (right == cam.right) && (bottom == cam.bottom) && (top == cam.top) && + (border_left == cam.border_left) && + (border_right == cam.border_right) && + (border_bottom == cam.border_bottom) && + (border_top == cam.border_top) && (matrix == cam.matrix) && (motion == cam.motion) && (use_motion == cam.use_motion) && diff --git a/intern/cycles/render/camera.h b/intern/cycles/render/camera.h index 7a09b5981e4..647423d88ba 100644 --- a/intern/cycles/render/camera.h +++ b/intern/cycles/render/camera.h @@ -67,6 +67,9 @@ public: int width, height; float left, right, bottom, top; + /* border */ + float border_left, border_right, border_bottom, border_top; + /* transformation */ Transform matrix; diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp index 34a0c0ff877..173d73ea2c7 100644 --- a/intern/cycles/render/session.cpp +++ b/intern/cycles/render/session.cpp @@ -27,6 +27,7 @@ #include "util_foreach.h" #include "util_function.h" +#include "util_opengl.h" #include "util_task.h" #include "util_time.h" diff --git a/intern/cycles/util/util_system.cpp b/intern/cycles/util/util_system.cpp index e8c81e57654..ad7f3347cee 100644 --- a/intern/cycles/util/util_system.cpp +++ b/intern/cycles/util/util_system.cpp @@ -152,7 +152,7 @@ bool system_cpu_support_optimized() /*__cpuid(result, 0x80000000); num_ex = result[0];*/ - if(num >= 1){ + if(num >= 1) { __cpuid(result, 0x00000001); caps.mmx = (result[3] & ((int)1 << 23)) != 0; caps.sse = (result[3] & ((int)1 << 25)) != 0; @@ -167,7 +167,7 @@ bool system_cpu_support_optimized() caps.fma3 = (result[2] & ((int)1 << 12)) != 0; } - /*if(num_ex >= 0x80000001){ + /*if(num_ex >= 0x80000001) { __cpuid(result, 0x80000001); caps.x64 = (result[3] & ((int)1 << 29)) != 0; caps.sse4a = (result[2] & ((int)1 << 6)) != 0; diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index 7614cb80e00..8454f338645 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -56,8 +56,7 @@ typedef unsigned long long GHOST_TUns64; typedef void *GHOST_TUserDataPtr; -typedef enum -{ +typedef enum { GHOST_kFailure = 0, GHOST_kSuccess } GHOST_TSuccess; diff --git a/intern/itasc/Armature.cpp b/intern/itasc/Armature.cpp index dd5c1921a98..1dacb8bc184 100644 --- a/intern/itasc/Armature.cpp +++ b/intern/itasc/Armature.cpp @@ -158,7 +158,7 @@ void Armature::pushQ(CacheTS timestamp) { if (m_qCCh >= 0) { // try to keep the cache if the joints are the same - m_cache->addCacheVectorIfDifferent(this, m_qCCh, timestamp, &m_qKdl(0), m_qKdl.rows(), KDL::epsilon); + m_cache->addCacheVectorIfDifferent(this, m_qCCh, timestamp, m_qKdl(0), m_qKdl.rows(), KDL::epsilon); m_qCTs = timestamp; } } @@ -170,8 +170,8 @@ bool Armature::popQ(CacheTS timestamp) double* item; item = (double*)m_cache->getPreviousCacheItem(this, m_qCCh, ×tamp); if (item && m_qCTs != timestamp) { - double& q = m_qKdl(0); - memcpy(&q, item, m_qKdl.rows()*sizeof(q)); + double* q = m_qKdl(0); + memcpy(q, item, m_qKdl.rows()*sizeof(double)); m_qCTs = timestamp; // changing the joint => recompute the jacobian updateJacobian(); @@ -255,7 +255,7 @@ bool Armature::getSegment(const std::string& name, const unsigned int q_size, co p_tip = &sit->second.segment.getFrameToTip(); for (unsigned int dof=0; dof<p_joint->getNDof(); dof++) { (&q_rest)[dof] = m_joints[sit->second.q_nr+dof].rest; - (&q)[dof] = m_qKdl(sit->second.q_nr+dof); + (&q)[dof] = m_qKdl[sit->second.q_nr+dof]; } return true; } @@ -267,7 +267,7 @@ double Armature::getMaxJointChange() double maxJoint = 0.0; for (unsigned int i=0; i<m_njoint; i++) { // this is a very rough calculation, it doesn't work well for spherical joint - double joint = fabs(m_oldqKdl(i)-m_qKdl(i)); + double joint = fabs(m_oldqKdl[i]-m_qKdl[i]); if (maxJoint < joint) maxJoint = joint; } @@ -392,7 +392,7 @@ bool Armature::finalize() m_newqKdl.resize(m_njoint); m_qdotKdl.resize(m_njoint); for (i=0; i<m_njoint; i++) { - m_newqKdl(i) = m_oldqKdl(i) = m_qKdl(i) = m_joints[i].rest; + m_newqKdl[i] = m_oldqKdl[i] = m_qKdl[i] = m_joints[i].rest; } updateJacobian(); // estimate the maximum size of the robot arms @@ -447,15 +447,15 @@ bool Armature::updateJoint(const Timestamp& timestamp, JointLockCallback& callba // integration and joint limit // for spherical joint we must use a more sophisticated method unsigned int q_nr; - double* qdot=&m_qdotKdl(0); - double* q=&m_qKdl(0); - double* newq=&m_newqKdl(0); + double* qdot=m_qdotKdl(0); + double* q=m_qKdl(0); + double* newq=m_newqKdl(0); double norm, qx, qz, CX, CZ, sx, sz; bool locked = false; int unlocked = 0; for (q_nr=0; q_nr<m_nq; ++q_nr) - m_qdotKdl(q_nr)=m_qdot(q_nr); + qdot[q_nr]=m_qdot[q_nr]; for (q_nr=0; q_nr<m_nq; ) { Joint_struct* joint = &m_joints[q_nr]; @@ -624,7 +624,7 @@ void Armature::updateKinematics(const Timestamp& timestamp){ return; // the new joint value have been computed already, just copy - memcpy(&m_qKdl(0), &m_newqKdl(0), sizeof(double)*m_qKdl.rows()); + memcpy(m_qKdl(0), m_newqKdl(0), sizeof(double)*m_qKdl.rows()); pushCache(timestamp); updateJacobian(); // here update the desired output. @@ -677,7 +677,7 @@ void Armature::updateControlOutput(const Timestamp& timestamp) if (!timestamp.substep) { // save previous joint state for getMaxJointChange() - memcpy(&m_oldqKdl(0), &m_qKdl(0), sizeof(double)*m_qKdl.rows()); + memcpy(m_oldqKdl(0), m_qKdl(0), sizeof(double)*m_qKdl.rows()); for (unsigned int i=0; i<m_neffector; i++) { m_effectors[i].oldpose = m_effectors[i].pose; } @@ -696,8 +696,8 @@ void Armature::updateControlOutput(const Timestamp& timestamp) JointConstraint_struct* pConstraint = *it; unsigned int nr, i; for (i=0, nr = pConstraint->segment->second.q_nr; i<pConstraint->v_nr; i++, nr++) { - *(double*)&pConstraint->value[i].y = m_qKdl(nr); - *(double*)&pConstraint->value[i].ydot = m_qdotKdl(nr); + *(double*)&pConstraint->value[i].y = m_qKdl[nr]; + *(double*)&pConstraint->value[i].ydot = m_qdotKdl[nr]; } if (pConstraint->function && (pConstraint->substep || (!timestamp.reiterate && !timestamp.substep))) { (*pConstraint->function)(timestamp, pConstraint->values, pConstraint->v_nr, pConstraint->param); diff --git a/intern/itasc/CMakeLists.txt b/intern/itasc/CMakeLists.txt index 3d24a0cb8c6..f4bc0326ea1 100644 --- a/intern/itasc/CMakeLists.txt +++ b/intern/itasc/CMakeLists.txt @@ -318,8 +318,5 @@ set(SRC ../../extern/Eigen3/Eigen/src/Cholesky/LLT.h ) -if(WIN32) - add_definitions(-DEIGEN_DONT_ALIGN_STATICALLY) -endif() blender_add_lib(bf_intern_itasc "${SRC}" "${INC}" "${INC_SYS}") diff --git a/intern/itasc/Distance.cpp b/intern/itasc/Distance.cpp index 7cf04367a4e..c9efca101e3 100644 --- a/intern/itasc/Distance.cpp +++ b/intern/itasc/Distance.cpp @@ -189,7 +189,7 @@ void Distance::updateKinematics(const Timestamp& timestamp) void Distance::updateJacobian() { for(unsigned int i=0;i<6;i++) - m_chiKdl(i)=m_chi(i); + m_chiKdl[i]=m_chi[i]; m_fksolver->JntToCart(m_chiKdl,m_internalPose); m_jacsolver->JntToJac(m_chiKdl,m_jac); diff --git a/intern/itasc/SConscript b/intern/itasc/SConscript index 69dddf40228..c1ad931c665 100644 --- a/intern/itasc/SConscript +++ b/intern/itasc/SConscript @@ -9,8 +9,5 @@ incs = '. ../../extern/Eigen3' defs = [] -if env['PLATFORM'] == 'win32': - defs.append('EIGEN_DONT_ALIGN_STATICALLY') - env.BlenderLib ('bf_intern_itasc', sources, Split(incs), defs, libtype=['intern','player'], priority=[20,100] ) diff --git a/intern/itasc/kdl/jntarray.cpp b/intern/itasc/kdl/jntarray.cpp index 77c75e6af6c..db2c913a532 100644 --- a/intern/itasc/kdl/jntarray.cpp +++ b/intern/itasc/kdl/jntarray.cpp @@ -71,20 +71,25 @@ namespace KDL SetToZero(*this); } - double JntArray::operator()(unsigned int i,unsigned int j)const + double JntArray::operator[](unsigned int i)const { - assert(i<size&&j==0); - assert(0 != size); // found JntArray containing no data + assert(i<size); return data[i]; } - double& JntArray::operator()(unsigned int i,unsigned int j) + double& JntArray::operator[](unsigned int i) { - assert(i<size&&j==0); - assert(0 != size); // found JntArray containing no data + assert(i<size); return data[i]; } + double* JntArray::operator()(unsigned int i) + { + if (i>=size) + return NULL; + return &data[i]; + } + unsigned int JntArray::rows()const { return size; diff --git a/intern/itasc/kdl/jntarray.hpp b/intern/itasc/kdl/jntarray.hpp index 8db4cd6f2b3..ece6b0bdb6b 100644 --- a/intern/itasc/kdl/jntarray.hpp +++ b/intern/itasc/kdl/jntarray.hpp @@ -107,24 +107,30 @@ class MyTask : public RTT::TaskContext JntArray& operator = ( const JntArray& arg); /** - * get_item operator for the joint array, if a second value is - * given it should be zero, since a JntArray resembles a column. + * get_item operator for the joint array * * * @return the joint value at position i, starting from 0 * @pre 0 != size (ie non-default constructor or resize() called) */ - double operator()(unsigned int i,unsigned int j=0)const; + double operator[](unsigned int i) const; /** - * set_item operator, again if a second value is given it - *should be zero. + * set_item operator * * @return reference to the joint value at position i,starting *from zero. * @pre 0 != size (ie non-default constructor or resize() called) */ - double& operator()(unsigned int i,unsigned int j=0); + double& operator[](unsigned int i); /** + * access operator for the joint array. Use pointer here to allow + * access to sequential joint angles (required for ndof joints) + * + * + * @return the joint value at position i, NULL if i is outside the valid range + */ + double* operator()(unsigned int i); + /** * Returns the number of rows (size) of the array * */ diff --git a/intern/itasc/kdl/joint.cpp b/intern/itasc/kdl/joint.cpp index 5458efc4fcf..161794ddd72 100644 --- a/intern/itasc/kdl/joint.cpp +++ b/intern/itasc/kdl/joint.cpp @@ -55,37 +55,45 @@ namespace KDL { { } - Frame Joint::pose(const double& q)const + Frame Joint::pose(const double* q)const { switch(type){ case RotX: - return Frame(Rotation::RotX(scale*q+offset)); + assert(q); + return Frame(Rotation::RotX(scale*q[0]+offset)); break; case RotY: - return Frame(Rotation::RotY(scale*q+offset)); + assert(q); + return Frame(Rotation::RotY(scale*q[0]+offset)); break; case RotZ: - return Frame(Rotation::RotZ(scale*q+offset)); + assert(q); + return Frame(Rotation::RotZ(scale*q[0]+offset)); break; case TransX: - return Frame(Vector(scale*q+offset,0.0,0.0)); + assert(q); + return Frame(Vector(scale*q[0]+offset,0.0,0.0)); break; case TransY: - return Frame(Vector(0.0,scale*q+offset,0.0)); + assert(q); + return Frame(Vector(0.0,scale*q[0]+offset,0.0)); break; case TransZ: - return Frame(Vector(0.0,0.0,scale*q+offset)); + assert(q); + return Frame(Vector(0.0,0.0,scale*q[0]+offset)); break; case Sphere: // the joint angles represent a rotation vector expressed in the base frame of the joint // (= the frame you get when there is no offset nor rotation) - return Frame(Rot(Vector((&q)[0], (&q)[1], (&q)[2]))); + assert(q); + return Frame(Rot(Vector(q[0], q[1], q[2]))); break; case Swing: // the joint angles represent a 2D rotation vector in the XZ planee of the base frame of the joint // (= the frame you get when there is no offset nor rotation) - return Frame(Rot(Vector((&q)[0], 0.0, (&q)[1]))); + assert(q); + return Frame(Rot(Vector(q[0], 0.0, q[1]))); break; default: return Frame::Identity(); diff --git a/intern/itasc/kdl/joint.hpp b/intern/itasc/kdl/joint.hpp index a1291509f0f..9d25b427499 100644 --- a/intern/itasc/kdl/joint.hpp +++ b/intern/itasc/kdl/joint.hpp @@ -70,7 +70,7 @@ namespace KDL { * * @return the resulting 6D-pose */ - Frame pose(const double& q)const; + Frame pose(const double* q)const; /** * Request the resulting 6D-velocity with a joint velocity qdot * diff --git a/intern/itasc/kdl/kinfam_io.cpp b/intern/itasc/kdl/kinfam_io.cpp index 15557ab5f05..ff4cab862ce 100644 --- a/intern/itasc/kdl/kinfam_io.cpp +++ b/intern/itasc/kdl/kinfam_io.cpp @@ -76,7 +76,7 @@ std::istream& operator >>(std::istream& is, Tree& tree) { std::ostream& operator <<(std::ostream& os, const JntArray& array) { os << "["; for (unsigned int i = 0; i < array.rows(); i++) - os << std::setw(KDL_FRAME_WIDTH) << array(i); + os << std::setw(KDL_FRAME_WIDTH) << array[i]; os << "]"; return os; } diff --git a/intern/itasc/kdl/segment.cpp b/intern/itasc/kdl/segment.cpp index cba797899e1..f963559c4c8 100644 --- a/intern/itasc/kdl/segment.cpp +++ b/intern/itasc/kdl/segment.cpp @@ -48,12 +48,12 @@ namespace KDL { { } - Frame Segment::pose(const double& q)const + Frame Segment::pose(const double* q)const { return joint.pose(q)*f_tip; } - Twist Segment::twist(const double& q, const double& qdot, int dof)const + Twist Segment::twist(const double* q, const double& qdot, int dof)const { return joint.twist(qdot, dof).RefPoint(pose(q).p); } diff --git a/intern/itasc/kdl/segment.hpp b/intern/itasc/kdl/segment.hpp index 87d972ead70..130bfb13f8b 100644 --- a/intern/itasc/kdl/segment.hpp +++ b/intern/itasc/kdl/segment.hpp @@ -73,7 +73,7 @@ namespace KDL { * * @return pose from the root to the tip of the segment */ - Frame pose(const double& q)const; + Frame pose(const double* q)const; /** * Request the 6D-velocity of the tip of the segment, given * the joint position q and the joint velocity qdot. @@ -85,7 +85,7 @@ namespace KDL { *in the base-frame of the segment(root) and with the tip of *the segment as reference point. */ - Twist twist(const double& q,const double& qdot, int dof=0)const; + Twist twist(const double* q,const double& qdot, int dof=0)const; /** * Request the 6D-velocity at a given point p, relative to base frame of the segment diff --git a/intern/itasc/kdl/utilities/utility.h b/intern/itasc/kdl/utilities/utility.h index fbf9982665a..892b375d442 100644 --- a/intern/itasc/kdl/utilities/utility.h +++ b/intern/itasc/kdl/utilities/utility.h @@ -27,6 +27,10 @@ #include <cassert> #include <cmath> +#ifdef NDEBUG +#undef assert +#define assert(e) ((void)0) +#endif ///////////////////////////////////////////////////////////// // configurable options for the frames library. diff --git a/intern/mikktspace/mikktspace.c b/intern/mikktspace/mikktspace.c index cba4c406759..0a3141d6782 100644 --- a/intern/mikktspace/mikktspace.c +++ b/intern/mikktspace/mikktspace.c @@ -40,8 +40,7 @@ #define INTERNAL_RND_SORT_SEED 39871946 // internal structure -typedef struct -{ +typedef struct { float x, y, z; } SVec3; @@ -119,14 +118,12 @@ static tbool VNotZero(const SVec3 v) -typedef struct -{ +typedef struct { int iNrFaces; int * pTriMembers; } SSubGroup; -typedef struct -{ +typedef struct { int iNrFaces; int * pFaceIndices; int iVertexRepresentitive; @@ -141,8 +138,7 @@ typedef struct -typedef struct -{ +typedef struct { int FaceNeighbors[3]; SGroup * AssignedGroup[3]; @@ -156,8 +152,7 @@ typedef struct unsigned char vert_num[4]; } STriInfo; -typedef struct -{ +typedef struct { SVec3 vOs; float fMagS; SVec3 vOt; @@ -426,8 +421,7 @@ tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThre /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -typedef struct -{ +typedef struct { float vert[3]; int index; } STmpVert; @@ -911,8 +905,7 @@ static SVec3 GetTexCoord(const SMikkTSpaceContext * pContext, const int index) ///////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////// -typedef union -{ +typedef union { struct { int i0, i1, f; diff --git a/intern/mikktspace/mikktspace.h b/intern/mikktspace/mikktspace.h index dc2308f6116..52c44a713c6 100644 --- a/intern/mikktspace/mikktspace.h +++ b/intern/mikktspace/mikktspace.h @@ -62,8 +62,7 @@ extern "C" { typedef int tbool; typedef struct SMikkTSpaceContext SMikkTSpaceContext; -typedef struct -{ +typedef struct { // Returns the number of faces (triangles/quads) on the mesh to be processed. int (*m_getNumFaces)(const SMikkTSpaceContext * pContext); diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h index 3475ef532da..bcda970e60c 100644 --- a/source/blender/blenkernel/BKE_cloth.h +++ b/source/blender/blenkernel/BKE_cloth.h @@ -69,8 +69,7 @@ struct CollisionTree; * own connectivity of the mesh based on the actual edges in the mesh. * */ -typedef struct Cloth -{ +typedef struct Cloth { struct ClothVertex *verts; /* The vertices that represent this cloth. */ struct LinkNode *springs; /* The springs connecting the mesh. */ unsigned int numverts; /* The number of verts == m * n. */ @@ -91,8 +90,7 @@ typedef struct Cloth /** * The definition of a cloth vertex. */ -typedef struct ClothVertex -{ +typedef struct ClothVertex { int flags; /* General flags per vertex. */ float v[3]; /* The velocity of the point. */ float xconst[3]; /* constrained position */ @@ -117,8 +115,7 @@ ClothVertex; /** * The definition of a spring. */ -typedef struct ClothSpring -{ +typedef struct ClothSpring { int ij; /* Pij from the paper, one end of the spring. */ int kl; /* Pkl from the paper, one end of the spring. */ float restlen; /* The original length of the spring. */ @@ -149,8 +146,7 @@ ClothSpring; /* SIMULATION FLAGS: goal flags,.. */ /* These are the bits used in SimSettings.flags. */ -typedef enum -{ +typedef enum { CLOTH_SIMSETTINGS_FLAG_COLLOBJ = ( 1 << 2 ),// object is only collision object, no cloth simulation is done CLOTH_SIMSETTINGS_FLAG_GOAL = ( 1 << 3 ), // we have goals enabled CLOTH_SIMSETTINGS_FLAG_TEARING = ( 1 << 4 ),// true if tearing is enabled @@ -160,15 +156,13 @@ typedef enum } CLOTH_SIMSETTINGS_FLAGS; /* COLLISION FLAGS */ -typedef enum -{ +typedef enum { CLOTH_COLLSETTINGS_FLAG_ENABLED = ( 1 << 1 ), /* enables cloth - object collisions */ CLOTH_COLLSETTINGS_FLAG_SELF = ( 1 << 2 ), /* enables selfcollisions */ } CLOTH_COLLISIONSETTINGS_FLAGS; /* Spring types as defined in the paper.*/ -typedef enum -{ +typedef enum { CLOTH_SPRING_TYPE_STRUCTURAL = (1 << 1), CLOTH_SPRING_TYPE_SHEAR = (1 << 2), CLOTH_SPRING_TYPE_BENDING = (1 << 3), @@ -176,8 +170,7 @@ typedef enum } CLOTH_SPRING_TYPES; /* SPRING FLAGS */ -typedef enum -{ +typedef enum { CLOTH_SPRING_FLAG_DEACTIVATE = ( 1 << 1 ), CLOTH_SPRING_FLAG_NEEDED = ( 1 << 2 ), // springs has values to be applied } CLOTH_SPRINGS_FLAGS; @@ -230,16 +223,14 @@ int cloth_add_spring (struct ClothModifierData *clmd, unsigned int indexA, unsig /* This enum provides the IDs for our solvers. */ // only one available in the moment -typedef enum -{ +typedef enum { CM_IMPLICIT = 0, } CM_SOLVER_ID; /* This structure defines how to call the solver. */ -typedef struct -{ +typedef struct { const char *name; CM_SOLVER_ID id; int ( *init ) (struct Object *ob, struct ClothModifierData *clmd ); diff --git a/source/blender/blenkernel/BKE_collision.h b/source/blender/blenkernel/BKE_collision.h index 191056571c0..ec257a2f394 100644 --- a/source/blender/blenkernel/BKE_collision.h +++ b/source/blender/blenkernel/BKE_collision.h @@ -59,8 +59,7 @@ struct LinkNode; //////////////////////////////////////// /* COLLISION FLAGS */ -typedef enum -{ +typedef enum { COLLISION_IN_FUTURE = (1 << 1), #ifdef WITH_ELTOPO COLLISION_USE_COLLFACE = (1 << 2), diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index bbe68db8bfe..3dc68edf12b 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -321,6 +321,7 @@ void CustomData_to_bmeshpoly(struct CustomData *fdata, struct CustomData *pdata, struct CustomData *ldata, int totloop, int totpoly); void CustomData_from_bmeshpoly(struct CustomData *fdata, struct CustomData *pdata, struct CustomData *ldata, int total); void CustomData_bmesh_update_active_layers(struct CustomData *fdata, struct CustomData *pdata, struct CustomData *ldata); +void CustomData_bmesh_do_versions_update_active_layers(struct CustomData *fdata, struct CustomData *pdata, struct CustomData *ldata); void CustomData_bmesh_init_pool(struct CustomData *data, int totelem, const char htype); /* External file storage */ diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h index 19feb4d8f2e..a93e811557a 100644 --- a/source/blender/blenkernel/BKE_mask.h +++ b/source/blender/blenkernel/BKE_mask.h @@ -122,15 +122,17 @@ void BKE_mask_update_display(struct Mask *mask, float ctime); void BKE_mask_evaluate_all_masks(struct Main *bmain, float ctime, const int do_newframe); void BKE_mask_update_scene(struct Main *bmain, struct Scene *scene, const int do_newframe); void BKE_mask_parent_init(struct MaskParent *parent); -void BKE_mask_calc_handle_adjacent_interp(struct Mask *mask, struct MaskSpline *spline, struct MaskSplinePoint *point, - const float u); -void BKE_mask_calc_tangent_polyline(struct Mask *mask, struct MaskSpline *spline, struct MaskSplinePoint *point, float t[2]); -void BKE_mask_calc_handle_point(struct Mask *mask, struct MaskSpline *spline, struct MaskSplinePoint *point); -void BKE_mask_calc_handle_point_auto(struct Mask *mask, struct MaskSpline *spline, struct MaskSplinePoint *point, +void BKE_mask_calc_handle_adjacent_interp(struct MaskSpline *spline, struct MaskSplinePoint *point, const float u); +void BKE_mask_calc_tangent_polyline(struct MaskSpline *spline, struct MaskSplinePoint *point, float t[2]); +void BKE_mask_calc_handle_point(struct MaskSpline *spline, struct MaskSplinePoint *point); +void BKE_mask_calc_handle_point_auto(struct MaskSpline *spline, struct MaskSplinePoint *point, const short do_recalc_length); -void BKE_mask_get_handle_point_adjacent(struct Mask *mask, struct MaskSpline *spline, struct MaskSplinePoint *point, +void BKE_mask_get_handle_point_adjacent(struct MaskSpline *spline, struct MaskSplinePoint *point, struct MaskSplinePoint **r_point_prev, struct MaskSplinePoint **r_point_next); +void BKE_mask_layer_calc_handles(struct MaskLayer *masklay); +void BKE_mask_layer_calc_handles_deform(struct MaskLayer *masklay); void BKE_mask_calc_handles(struct Mask *mask); +void BKE_mask_calc_handles_deform(struct Mask *mask); void BKE_mask_spline_ensure_deform(struct MaskSpline *spline); /* animation */ diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 1878e43f577..887340622ad 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -151,6 +151,7 @@ void copy_dverts(struct MDeformVert *dst, struct MDeformVert *src, int totvert); void BKE_mesh_delete_material_index(struct Mesh *me, short index); void BKE_mesh_smooth_flag_set(struct Object *meshOb, int enableSmooth); void BKE_mesh_convert_mfaces_to_mpolys(struct Mesh *mesh); +void BKE_mesh_do_versions_convert_mfaces_to_mpolys(struct Mesh *mesh); void BKE_mesh_convert_mfaces_to_mpolys_ex(struct ID *id, struct CustomData *fdata, struct CustomData *ldata, struct CustomData *pdata, int totedge_i, int totface_i, int totloop_i, int totpoly_i, diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 351cb7dbb8b..eaaa1d8b62e 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -266,8 +266,7 @@ struct bNodeTreeExec; typedef void (*bNodeTreeCallback)(void *calldata, struct ID *owner_id, struct bNodeTree *ntree); typedef void (*bNodeClassCallback)(void *calldata, int nclass, const char *name); -typedef struct bNodeTreeType -{ +typedef struct bNodeTreeType { int type; /* type identifier */ char idname[64]; /* id name for RNA identification */ diff --git a/source/blender/blenkernel/BKE_sketch.h b/source/blender/blenkernel/BKE_sketch.h index 50ee1184b3e..ed7ce05506d 100644 --- a/source/blender/blenkernel/BKE_sketch.h +++ b/source/blender/blenkernel/BKE_sketch.h @@ -26,14 +26,12 @@ * \ingroup bke */ -typedef enum SK_PType -{ +typedef enum SK_PType { PT_CONTINUOUS, PT_EXACT, } SK_PType; -typedef enum SK_PMode -{ +typedef enum SK_PMode { PT_SNAP, PT_PROJECT, } SK_PMode; diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 5dc50dca45a..f551b2d18a4 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -2219,6 +2219,48 @@ void CustomData_bmesh_update_active_layers(CustomData *fdata, CustomData *pdata, } } +/* update active indices for active/render/clone/stencil custom data layers + * based on indices from fdata layers + * used by do_versions in readfile.c when creating pdata and ldata for pre-bmesh + * meshes and needed to preserve active/render/clone/stencil flags set in pre-bmesh files + */ +void CustomData_bmesh_do_versions_update_active_layers(CustomData *fdata, CustomData *pdata, CustomData *ldata) +{ + int act; + + if (CustomData_has_layer(fdata, CD_MTFACE)) { + act = CustomData_get_active_layer(fdata, CD_MTFACE); + CustomData_set_layer_active(pdata, CD_MTEXPOLY, act); + CustomData_set_layer_active(ldata, CD_MLOOPUV, act); + + act = CustomData_get_render_layer(fdata, CD_MTFACE); + CustomData_set_layer_render(pdata, CD_MTEXPOLY, act); + CustomData_set_layer_render(ldata, CD_MLOOPUV, act); + + act = CustomData_get_clone_layer(fdata, CD_MTFACE); + CustomData_set_layer_clone(pdata, CD_MTEXPOLY, act); + CustomData_set_layer_clone(ldata, CD_MLOOPUV, act); + + act = CustomData_get_stencil_layer(fdata, CD_MTFACE); + CustomData_set_layer_stencil(pdata, CD_MTEXPOLY, act); + CustomData_set_layer_stencil(ldata, CD_MLOOPUV, act); + } + + if (CustomData_has_layer(fdata, CD_MCOL)) { + act = CustomData_get_active_layer(fdata, CD_MCOL); + CustomData_set_layer_active(ldata, CD_MLOOPCOL, act); + + act = CustomData_get_render_layer(fdata, CD_MCOL); + CustomData_set_layer_render(ldata, CD_MLOOPCOL, act); + + act = CustomData_get_clone_layer(fdata, CD_MCOL); + CustomData_set_layer_clone(ldata, CD_MLOOPCOL, act); + + act = CustomData_get_stencil_layer(fdata, CD_MCOL); + CustomData_set_layer_stencil(ldata, CD_MLOOPCOL, act); + } +} + void CustomData_bmesh_init_pool(CustomData *data, int totelem, const char htype) { int chunksize; diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index d4861a27057..4aef47159df 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -695,8 +695,7 @@ DO_INLINE void subadd_bfmatrixS_bfmatrixS( fmatrix3x3 *to, fmatrix3x3 *from, flo /////////////////////////////////////////////////////////////////// // simulator start /////////////////////////////////////////////////////////////////// -typedef struct Implicit_Data -{ +typedef struct Implicit_Data { lfVector *X, *V, *Xnew, *Vnew, *olddV, *F, *B, *dV, *z; fmatrix3x3 *A, *dFdV, *dFdX, *S, *P, *Pinv, *bigI, *M; } Implicit_Data; diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index aaefa558c9b..0a6063a6b21 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -1228,26 +1228,25 @@ static void mask_calc_point_handle(MaskSplinePoint *point, MaskSplinePoint *poin #endif } -void BKE_mask_get_handle_point_adjacent(Mask *UNUSED(mask), MaskSpline *spline, MaskSplinePoint *point, +void BKE_mask_get_handle_point_adjacent(MaskSpline *spline, MaskSplinePoint *point, MaskSplinePoint **r_point_prev, MaskSplinePoint **r_point_next) { - int i = (int)(point - spline->points); - BLI_assert(i >= i && i < spline->tot_point); - (void)i; /* quiet release builds */ + /* TODO, could avoid calling this at such low level */ + MaskSplinePoint *points_array = BKE_mask_spline_point_array_from_point(spline, point); - *r_point_prev = mask_spline_point_prev(spline, spline->points, point); - *r_point_next = mask_spline_point_next(spline, spline->points, point); + *r_point_prev = mask_spline_point_prev(spline, points_array, point); + *r_point_next = mask_spline_point_next(spline, points_array, point); } /* calculates the tanget of a point by its previous and next * (ignoring handles - as if its a poly line) */ -void BKE_mask_calc_tangent_polyline(Mask *mask, MaskSpline *spline, MaskSplinePoint *point, float t[2]) +void BKE_mask_calc_tangent_polyline(MaskSpline *spline, MaskSplinePoint *point, float t[2]) { float tvec_a[2], tvec_b[2]; MaskSplinePoint *point_prev, *point_next; - BKE_mask_get_handle_point_adjacent(mask, spline, point, + BKE_mask_get_handle_point_adjacent(spline, point, &point_prev, &point_next); if (point_prev) { @@ -1270,11 +1269,11 @@ void BKE_mask_calc_tangent_polyline(Mask *mask, MaskSpline *spline, MaskSplinePo normalize_v2(t); } -void BKE_mask_calc_handle_point(Mask *mask, MaskSpline *spline, MaskSplinePoint *point) +void BKE_mask_calc_handle_point(MaskSpline *spline, MaskSplinePoint *point) { MaskSplinePoint *point_prev, *point_next; - BKE_mask_get_handle_point_adjacent(mask, spline, point, + BKE_mask_get_handle_point_adjacent(spline, point, &point_prev, &point_next); mask_calc_point_handle(point, point_prev, point_next); @@ -1291,7 +1290,7 @@ static void enforce_dist_v2_v2fl(float v1[2], const float v2[2], const float dis } } -void BKE_mask_calc_handle_adjacent_interp(Mask *mask, MaskSpline *spline, MaskSplinePoint *point, const float u) +void BKE_mask_calc_handle_adjacent_interp(MaskSpline *spline, MaskSplinePoint *point, const float u) { /* TODO! - make this interpolate between siblings - not always midpoint! */ int length_tot = 0; @@ -1303,7 +1302,7 @@ void BKE_mask_calc_handle_adjacent_interp(Mask *mask, MaskSpline *spline, MaskSp BLI_assert(u >= 0.0f && u <= 1.0f); - BKE_mask_get_handle_point_adjacent(mask, spline, point, + BKE_mask_get_handle_point_adjacent(spline, point, &point_prev, &point_next); if (point_prev && point_next) { @@ -1344,7 +1343,7 @@ void BKE_mask_calc_handle_adjacent_interp(Mask *mask, MaskSpline *spline, MaskSp * * Useful for giving sane defaults. */ -void BKE_mask_calc_handle_point_auto(Mask *mask, MaskSpline *spline, MaskSplinePoint *point, +void BKE_mask_calc_handle_point_auto(MaskSpline *spline, MaskSplinePoint *point, const short do_recalc_length) { MaskSplinePoint *point_prev, *point_next; @@ -1353,7 +1352,7 @@ void BKE_mask_calc_handle_point_auto(Mask *mask, MaskSpline *spline, MaskSplineP (len_v3v3(point->bezt.vec[0], point->bezt.vec[1]) + len_v3v3(point->bezt.vec[1], point->bezt.vec[2])) / 2.0f; - BKE_mask_get_handle_point_adjacent(mask, spline, point, + BKE_mask_get_handle_point_adjacent(spline, point, &point_prev, &point_next); point->bezt.h1 = HD_AUTO; @@ -1370,25 +1369,33 @@ void BKE_mask_calc_handle_point_auto(Mask *mask, MaskSpline *spline, MaskSplineP } } +void BKE_mask_layer_calc_handles(MaskLayer *masklay) +{ + MaskSpline *spline; + for (spline = masklay->splines.first; spline; spline = spline->next) { + int i; + for (i = 0; i < spline->tot_point; i++) { + BKE_mask_calc_handle_point(spline, &spline->points[i]); + } + } +} + +void BKE_mask_layer_calc_handles_deform(MaskLayer *masklay) +{ + MaskSpline *spline; + for (spline = masklay->splines.first; spline; spline = spline->next) { + int i; + for (i = 0; i < spline->tot_point; i++) { + BKE_mask_calc_handle_point(spline, &spline->points_deform[i]); + } + } +} + void BKE_mask_calc_handles(Mask *mask) { MaskLayer *masklay; - for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { - MaskSpline *spline; - - for (spline = masklay->splines.first; spline; spline = spline->next) { - int i; - - for (i = 0; i < spline->tot_point; i++) { - BKE_mask_calc_handle_point(mask, spline, &spline->points[i]); - - /* could be done in a different function... */ - if (spline->points_deform) { - BKE_mask_calc_handle_point(mask, spline, &spline->points[i]); - } - } - } + BKE_mask_layer_calc_handles(masklay); } } @@ -1501,9 +1508,10 @@ void BKE_mask_evaluate(Mask *mask, float ctime, const int do_newframe) for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { MaskSpline *spline; - int i; for (spline = masklay->splines.first; spline; spline = spline->next) { + int i; + int has_auto = FALSE; BKE_mask_spline_ensure_deform(spline); @@ -1522,7 +1530,22 @@ void BKE_mask_evaluate(Mask *mask, float ctime, const int do_newframe) add_v2_v2(point_deform->bezt.vec[1], delta); add_v2_v2(point_deform->bezt.vec[2], delta); } + + if (point->bezt.h1 == HD_AUTO) { + has_auto = TRUE; + } + } + + /* if the spline has auto handles, these need to be recalculated after deformation */ + if (has_auto) { + for (i = 0; i < spline->tot_point; i++) { + MaskSplinePoint *point_deform = &spline->points_deform[i]; + if (point_deform->bezt.h1 == HD_AUTO) { + BKE_mask_calc_handle_point(spline, point_deform); + } + } } + /* end extra calc handles loop */ } } } diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index ed93f27fe5c..d0b9e73e295 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -2038,6 +2038,28 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh) mesh_update_customdata_pointers(mesh, TRUE); } +/* the same as BKE_mesh_convert_mfaces_to_mpolys but oriented to be used in do_versions from readfile.c + * the difference is how active/render/clone/stencil indices are handled here + * + * normally thay're being set from pdata which totally makes sense for meshes which are already + * converted to bmesh structures, but when loading older files indices shall be updated in other + * way around, so newly added pdata and ldata would have this indices set based on fdata layer + * + * this is normally only needed when reading older files, in all other cases BKE_mesh_convert_mfaces_to_mpolys + * shall be always used + */ +void BKE_mesh_do_versions_convert_mfaces_to_mpolys(Mesh *mesh) +{ + BKE_mesh_convert_mfaces_to_mpolys_ex(&mesh->id, &mesh->fdata, &mesh->ldata, &mesh->pdata, + mesh->totedge, mesh->totface, mesh->totloop, mesh->totpoly, + mesh->medge, mesh->mface, + &mesh->totloop, &mesh->totpoly, &mesh->mloop, &mesh->mpoly); + + CustomData_bmesh_do_versions_update_active_layers(&mesh->fdata, &mesh->pdata, &mesh->ldata); + + mesh_update_customdata_pointers(mesh, TRUE); +} + void BKE_mesh_convert_mfaces_to_mpolys_ex(ID *id, CustomData *fdata, CustomData *ldata, CustomData *pdata, int totedge_i, int totface_i, int totloop_i, int totpoly_i, MEdge *medge, MFace *mface, diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 04631729d7a..a01024acfd3 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -115,8 +115,6 @@ #include "GPU_material.h" /* Local function protos */ -static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul); - float originmat[3][3]; /* after BKE_object_where_is_calc(), can be used in other functions (bad!) */ void BKE_object_workob_clear(Object *workob) @@ -1904,109 +1902,6 @@ static void ob_parvert3(Object *ob, Object *par, float mat[][4]) } } -static int where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat[4][4]) -{ - float *fp1, *fp2; - float fac1, fac2; - int a; - - // include framerate - fac1 = (1.0f / (1.0f + fabsf(ob->sf)) ); - if (fac1 >= 1.0f) return 0; - fac2 = 1.0f - fac1; - - fp1 = obmat[0]; - fp2 = slowmat[0]; - for (a = 0; a < 16; a++, fp1++, fp2++) { - fp1[0] = fac1 * fp1[0] + fac2 * fp2[0]; - } - - return 1; -} - -void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime) -{ - float slowmat[4][4] = MAT4_UNITY; - float stime = ctime; - - /* new version: correct parent+vertexparent and track+parent */ - /* this one only calculates direct attached parent and track */ - /* is faster, but should keep track of timeoffs */ - - if (ob == NULL) return; - - /* execute drivers only, as animation has already been done */ - BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_DRIVERS); - - if (ob->parent) { - Object *par = ob->parent; - - /* hurms, code below conflicts with depgraph... (ton) */ - /* and even worse, it gives bad effects for NLA stride too (try ctime != par->ctime, with MBlur) */ - if (stime != par->ctime) { - // only for ipo systems? - Object tmp = *par; - - if (par->proxy_from) ; // was a copied matrix, no where_is! bad... - else BKE_object_where_is_calc_time(scene, par, ctime); - - solve_parenting(scene, ob, par, ob->obmat, slowmat, 0); - - *par = tmp; - } - else - solve_parenting(scene, ob, par, ob->obmat, slowmat, 0); - - /* "slow parent" is definitely not threadsafe, and may also give bad results jumping around - * An old-fashioned hack which probably doesn't really cut it anymore - */ - if (ob->partype & PARSLOW) { - if (!where_is_object_parslow(ob, ob->obmat, slowmat)) - return; - } - } - else { - BKE_object_to_mat4(ob, ob->obmat); - } - - /* solve constraints */ - if (ob->constraints.first && !(ob->transflag & OB_NO_CONSTRAINTS)) { - bConstraintOb *cob; - - cob = constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); - - /* constraints need ctime, not stime. Some call BKE_object_where_is_calc_time and bsystem_time */ - solve_constraints(&ob->constraints, cob, ctime); - - constraints_clear_evalob(cob); - } - - /* set negative scale flag in object */ - if (is_negative_m4(ob->obmat)) ob->transflag |= OB_NEG_SCALE; - else ob->transflag &= ~OB_NEG_SCALE; -} - -/* get object transformation matrix without recalculating dependencies and - * constraints -- assume dependencies are already solved by depsgraph. - * no changes to object and it's parent would be done. - * used for bundles orientation in 3d space relative to parented blender camera */ -void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4]) -{ - float slowmat[4][4] = MAT4_UNITY; - - if (ob->parent) { - Object *par = ob->parent; - - solve_parenting(scene, ob, par, obmat, slowmat, 1); - - if (ob->partype & PARSLOW) - where_is_object_parslow(ob, obmat, slowmat); - } - else { - BKE_object_to_mat4(ob, obmat); - } -} - static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul) { float totmat[4][4]; @@ -2028,11 +1923,11 @@ static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[] ok = 1; } } - + if (ok) mul_serie_m4(totmat, par->obmat, tmat, NULL, NULL, NULL, NULL, NULL, NULL); else copy_m4_m4(totmat, par->obmat); - + break; case PARBONE: ob_parbone(ob, par, tmat); @@ -2052,7 +1947,7 @@ static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[] break; case PARVERT3: ob_parvert3(ob, par, tmat); - + mul_serie_m4(totmat, par->obmat, tmat, NULL, NULL, NULL, NULL, NULL, NULL); break; @@ -2083,7 +1978,87 @@ static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[] copy_v3_v3(ob->orig, totmat[3]); } } +} + +static int where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat[4][4]) +{ + float *fp1, *fp2; + float fac1, fac2; + int a; + + // include framerate + fac1 = (1.0f / (1.0f + fabsf(ob->sf)) ); + if (fac1 >= 1.0f) return 0; + fac2 = 1.0f - fac1; + + fp1 = obmat[0]; + fp2 = slowmat[0]; + for (a = 0; a < 16; a++, fp1++, fp2++) { + fp1[0] = fac1 * fp1[0] + fac2 * fp2[0]; + } + + return 1; +} + +void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime) +{ + if (ob == NULL) return; + + /* execute drivers only, as animation has already been done */ + BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_DRIVERS); + + if (ob->parent) { + Object *par = ob->parent; + float slowmat[4][4] = MAT4_UNITY; + + /* calculate parent matrix */ + solve_parenting(scene, ob, par, ob->obmat, slowmat, 0); + + /* "slow parent" is definitely not threadsafe, and may also give bad results jumping around + * An old-fashioned hack which probably doesn't really cut it anymore + */ + if (ob->partype & PARSLOW) { + if (!where_is_object_parslow(ob, ob->obmat, slowmat)) + return; + } + } + else { + BKE_object_to_mat4(ob, ob->obmat); + } + + /* solve constraints */ + if (ob->constraints.first && !(ob->transflag & OB_NO_CONSTRAINTS)) { + bConstraintOb *cob; + + cob = constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); + solve_constraints(&ob->constraints, cob, ctime); + constraints_clear_evalob(cob); + } + + /* set negative scale flag in object */ + if (is_negative_m4(ob->obmat)) ob->transflag |= OB_NEG_SCALE; + else ob->transflag &= ~OB_NEG_SCALE; +} +/* get object transformation matrix without recalculating dependencies and + * constraints -- assume dependencies are already solved by depsgraph. + * no changes to object and it's parent would be done. + * used for bundles orientation in 3d space relative to parented blender camera */ +void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4]) +{ + float slowmat[4][4] = MAT4_UNITY; + + if (ob->parent) { + Object *par = ob->parent; + + solve_parenting(scene, ob, par, obmat, slowmat, 1); + + if (ob->partype & PARSLOW) + where_is_object_parslow(ob, obmat, slowmat); + } + else { + BKE_object_to_mat4(ob, obmat); + } } void BKE_object_where_is_calc(struct Scene *scene, Object *ob) @@ -2091,7 +2066,6 @@ void BKE_object_where_is_calc(struct Scene *scene, Object *ob) BKE_object_where_is_calc_time(scene, ob, (float)scene->r.cfra); } - void BKE_object_where_is_calc_simul(Scene *scene, Object *ob) /* was written for the old game engine (until 2.04) */ /* It seems that this function is only called diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index f19dfe74a36..6c7336958b5 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2363,13 +2363,12 @@ static EdgeHash *sph_springhash_build(ParticleSystem *psys) } #define SPH_NEIGHBORS 512 -typedef struct SPHNeighbor -{ +typedef struct SPHNeighbor { ParticleSystem *psys; int index; } SPHNeighbor; -typedef struct SPHRangeData -{ + +typedef struct SPHRangeData { SPHNeighbor neighbors[SPH_NEIGHBORS]; int tot_neighbors; @@ -2641,8 +2640,7 @@ static void sph_integrate(ParticleSimulationData *sim, ParticleData *pa, float d /************************************************/ /* Basic physics */ /************************************************/ -typedef struct EfData -{ +typedef struct EfData { ParticleTexture ptex; ParticleSimulationData *sim; ParticleData *pa; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index d9f1a6372ee..1113555e3bf 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -610,8 +610,6 @@ void BKE_scene_set_background(Main *bmain, Scene *scene) /* not too nice... for recovering objects with lost data */ //if (ob->pose == NULL) base->flag &= ~OB_POSEMODE; ob->flag = base->flag; - - ob->ctime = -1234567.0; /* force ipo to be calculated later */ } /* no full animation update, this to enable render code to work (render code calls own animation updates) */ } diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c index f1f3dd47d8b..ea4699f8495 100644 --- a/source/blender/blenkernel/intern/seqcache.c +++ b/source/blender/blenkernel/intern/seqcache.c @@ -38,8 +38,7 @@ #include "IMB_moviecache.h" -typedef struct seqCacheKey -{ +typedef struct seqCacheKey { struct Sequence * seq; SeqRenderData context; float cfra; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 588a6826919..cc5abce64f3 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3684,7 +3684,7 @@ static void lib_link_mesh(FileData *fd, Main *main) Main *gmain = G.main; G.main = main; - BKE_mesh_convert_mfaces_to_mpolys(me); + BKE_mesh_do_versions_convert_mfaces_to_mpolys(me); G.main = gmain; } diff --git a/source/blender/bmesh/intern/bmesh_marking.h b/source/blender/bmesh/intern/bmesh_marking.h index 12ebaedac60..406971652dc 100644 --- a/source/blender/bmesh/intern/bmesh_marking.h +++ b/source/blender/bmesh/intern/bmesh_marking.h @@ -27,8 +27,7 @@ * \ingroup bmesh */ -typedef struct BMEditSelection -{ +typedef struct BMEditSelection { struct BMEditSelection *next, *prev; BMElem *ele; char htype; @@ -82,7 +81,7 @@ void BM_editselection_plane(BMEditSelection *ese, float r_plane[3]); #define BM_select_history_store_notest(bm, ele) _bm_select_history_store_notest(bm, &(ele)->head) #define BM_select_history_store(bm, ele) _bm_select_history_store(bm, &(ele)->head) -int _bm_select_history_check(BMesh *bm, const BMHeader *ele); +int _bm_select_history_check(BMesh *bm, const BMHeader *ele); int _bm_select_history_remove(BMesh *bm, BMHeader *ele); void _bm_select_history_store_notest(BMesh *bm, BMHeader *ele); void _bm_select_history_store(BMesh *bm, BMHeader *ele); diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c index d90bd96a6f1..91c342ec070 100644 --- a/source/blender/editors/armature/editarmature_retarget.c +++ b/source/blender/editors/armature/editarmature_retarget.c @@ -81,20 +81,17 @@ typedef struct RetargetParam { bContext *context; } RetargetParam; -typedef enum -{ +typedef enum { RETARGET_LENGTH, RETARGET_AGGRESSIVE } RetargetMode; -typedef enum -{ +typedef enum { METHOD_BRUTE_FORCE = 0, METHOD_MEMOIZE = 1 } RetargetMethod; -typedef enum -{ +typedef enum { ARC_FREE = 0, ARC_TAKEN = 1, ARC_USED = 2 diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h index c4d7197bfa1..42036d1ea17 100644 --- a/source/blender/editors/include/ED_transform.h +++ b/source/blender/editors/include/ED_transform.h @@ -168,8 +168,7 @@ typedef struct DepthPeel { struct ListBase; -typedef enum SnapMode -{ +typedef enum SnapMode { SNAP_ALL = 0, SNAP_NOT_SELECTED = 1, SNAP_NOT_OBEDIT = 2 diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c index f8c36e866d7..7ffff2b06e5 100644 --- a/source/blender/editors/mask/mask_add.c +++ b/source/blender/editors/mask/mask_add.c @@ -235,7 +235,7 @@ static void setup_vertex_point(bContext *C, Mask *mask, MaskSpline *spline, Mask add_v2_v2(bezt->vec[2], vec); if (reference_adjacent) { - BKE_mask_calc_handle_adjacent_interp(mask, spline, new_point, u); + BKE_mask_calc_handle_adjacent_interp(spline, new_point, u); } } else { @@ -287,8 +287,8 @@ static void setup_vertex_point(bContext *C, Mask *mask, MaskSpline *spline, Mask add_v2_v2(bezt->vec[0], vec); sub_v2_v2(bezt->vec[2], vec); #else - BKE_mask_calc_handle_point_auto(mask, spline, new_point, TRUE); - BKE_mask_calc_handle_adjacent_interp(mask, spline, new_point, u); + BKE_mask_calc_handle_point_auto(spline, new_point, TRUE); + BKE_mask_calc_handle_adjacent_interp(spline, new_point, u); #endif } @@ -425,7 +425,7 @@ static int add_vertex_extrude(bContext *C, Mask *mask, MaskLayer *masklay, const if ((spline->flag & MASK_SPLINE_CYCLIC) || (point_index > 0 && point_index != spline->tot_point - 1)) { - BKE_mask_calc_tangent_polyline(mask, spline, point, tangent_point); + BKE_mask_calc_tangent_polyline(spline, point, tangent_point); sub_v2_v2v2(tangent_co, co, point->bezt.vec[1]); if (dot_v2v2(tangent_point, tangent_co) < 0.0f) { @@ -487,7 +487,7 @@ static int add_vertex_extrude(bContext *C, Mask *mask, MaskLayer *masklay, const if (do_recalc_src) { /* TODO, update keyframes in time */ - BKE_mask_calc_handle_point_auto(mask, spline, ref_point, FALSE); + BKE_mask_calc_handle_point_auto(spline, ref_point, FALSE); } WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask); @@ -572,8 +572,8 @@ static int add_vertex_exec(bContext *C, wmOperator *op) spline->flag |= MASK_SPLINE_CYCLIC; /* TODO, update keyframes in time */ - BKE_mask_calc_handle_point_auto(mask, spline, point, FALSE); - BKE_mask_calc_handle_point_auto(mask, spline, point_other, FALSE); + BKE_mask_calc_handle_point_auto(spline, point, FALSE); + BKE_mask_calc_handle_point_auto(spline, point_other, FALSE); /* TODO: only update this spline */ BKE_mask_update_display(mask, CTX_data_scene(C)->r.cfra); diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index d84214413da..a535e888156 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -102,8 +102,7 @@ typedef struct ThumbnailJob { ReportList reports; } ThumbnailJob; -typedef struct FileList -{ +typedef struct FileList { struct direntry *filelist; int *fidx; int numfiles; @@ -124,8 +123,7 @@ typedef struct FileList } FileList; -typedef struct FolderList -{ +typedef struct FolderList { struct FolderList *next, *prev; char *foldername; } FolderList; diff --git a/source/blender/editors/space_file/filelist.h b/source/blender/editors/space_file/filelist.h index fac6a387b9f..7a37c5fb3c5 100644 --- a/source/blender/editors/space_file/filelist.h +++ b/source/blender/editors/space_file/filelist.h @@ -53,8 +53,7 @@ typedef enum FileSelType { FILE_SEL_TOGGLE = 2 } FileSelType; -typedef enum FileCheckType -{ +typedef enum FileCheckType { CHECK_DIRS = 1, CHECK_FILES = 2, CHECK_ALL = 3 diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index 35b1583b24e..9e873799f1c 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -50,8 +50,7 @@ struct bNodeLink; struct Main; /* temp data to pass on to modal */ -typedef struct bNodeLinkDrag -{ +typedef struct bNodeLinkDrag { struct bNodeLinkDrag *next, *prev; /* List of links dragged by the operator. diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 547e8288d20..483016b7e00 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -69,6 +69,9 @@ #include "outliner_intern.h" +/* disable - this is far too slow - campbell */ +// #define USE_GROUP_SELECT + /* ****************************************************** */ /* Tree Size Functions */ @@ -207,6 +210,7 @@ static int group_restrict_flag(Group *gr, int flag) return 1; } +#ifdef USE_GROUP_SELECT static int group_select_flag(Group *gr) { GroupObject *gob; @@ -217,6 +221,7 @@ static int group_select_flag(Group *gr) return 0; } +#endif void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag) { @@ -422,16 +427,26 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar gr = (Group *)tselem->id; uiBlockSetEmboss(block, UI_EMBOSSN); - + +#ifndef USE_GROUP_SELECT + restrict_bool = FALSE; +#endif + +#ifdef USE_GROUP_SELECT restrict_bool = group_restrict_flag(gr, OB_RESTRICT_VIEW); +#endif bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, NULL, 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); uiButSetFunc(bt, restrictbutton_gr_restrict_view, scene, gr); +#ifdef USE_GROUP_SELECT restrict_bool = group_restrict_flag(gr, OB_RESTRICT_SELECT); +#endif bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_SELECT_ON : ICON_RESTRICT_SELECT_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, NULL, 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); uiButSetFunc(bt, restrictbutton_gr_restrict_select, scene, gr); - + +#ifdef USE_GROUP_SELECT restrict_bool = group_restrict_flag(gr, OB_RESTRICT_RENDER); +#endif bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_RENDER_ON : ICON_RESTRICT_RENDER_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, NULL, 0, 0, 0, 0, "Restrict/Allow renderability"); uiButSetFunc(bt, restrictbutton_gr_restrict_render, scene, gr); @@ -1274,8 +1289,8 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene } } else if (te->idcode == ID_GR) { +#ifdef USE_GROUP_SELECT Group *gr = (Group *)tselem->id; - if (group_select_flag(gr)) { char col[4]; UI_GetThemeColorType4ubv(TH_SELECT, SPACE_VIEW3D, col); @@ -1284,6 +1299,7 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene active = 2; } +#endif } else if (te->idcode == ID_OB) { Object *ob = (Object *)tselem->id; diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index b556fbf5c9d..e656b1242ab 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -385,6 +385,18 @@ static void group_linkobs2scene_cb(bContext *UNUSED(C), Scene *scene, TreeElemen } } +static void group_instance_cb(bContext *C, Scene *scene, TreeElement *UNUSED(te), + TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) +{ + Group *group = (Group *)tselem->id; + + Object *ob = ED_object_add_type(C, OB_EMPTY, scene->cursor, NULL, FALSE, scene->layact); + rename_id(&ob->id, group->id.name + 2); + ob->dup_group = group; + ob->transflag |= OB_DUPLIGROUP; + id_lib_extern(&group->id); +} + void outliner_do_object_operation(bContext *C, Scene *scene_act, SpaceOops *soops, ListBase *lb, void (*operation_cb)(bContext *C, Scene *scene, TreeElement *, TreeStoreElem *, TreeStoreElem *)) @@ -636,13 +648,14 @@ void OUTLINER_OT_object_operation(wmOperatorType *ot) /* **************************************** */ static EnumPropertyItem prop_group_op_types[] = { - {1, "UNLINK", 0, "Unlink", ""}, - {2, "LOCAL", 0, "Make Local", ""}, - {3, "LINK", 0, "Link Group Objects to Scene", ""}, - {4, "TOGVIS", 0, "Toggle Visible", ""}, - {5, "TOGSEL", 0, "Toggle Selectable", ""}, - {6, "TOGREN", 0, "Toggle Renderable", ""}, - {7, "RENAME", 0, "Rename", ""}, + {0, "UNLINK", 0, "Unlink Group", ""}, + {1, "LOCAL", 0, "Make Local Group", ""}, + {2, "LINK", 0, "Link Group Objects to Scene", ""}, + {3, "INSTANCE", 0, "Instance Group in Scene", ""}, + {4, "TOGVIS", 0, "Toggle Visible Group", ""}, + {5, "TOGSEL", 0, "Toggle Selectable", ""}, + {6, "TOGREN", 0, "Toggle Renderable", ""}, + {7, "RENAME", 0, "Rename", ""}, {0, NULL, 0, NULL, NULL} }; @@ -651,45 +664,36 @@ static int outliner_group_operation_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); SpaceOops *soops = CTX_wm_space_outliner(C); int event; - const char *str = NULL; /* check for invalid states */ if (soops == NULL) return OPERATOR_CANCELLED; event = RNA_enum_get(op->ptr, "type"); - - if (event == 1) { - outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_group_cb); - str = "Unlink group"; - } - else if (event == 2) { - outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb); - str = "Localized Data"; - } - else if (event == 3) { - outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_linkobs2scene_cb); - str = "Link Group Objects to Scene"; - } - else if (event == 4) { - outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_visibility_cb); - str = "Toggle Visibility"; - } - else if (event == 5) { - outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_selectability_cb); - str = "Toggle Selectability"; - } - else if (event == 6) { - outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_renderability_cb); - str = "Toggle Renderability"; - } - else if (event == 7) { - outliner_do_libdata_operation(C, scene, soops, &soops->tree, item_rename_cb); - str = "Rename"; + + switch (event) { + case 0: outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_group_cb); break; + case 1: outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb); break; + case 2: outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_linkobs2scene_cb); break; + case 3: outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_instance_cb); break; + case 4: outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_visibility_cb); break; + case 5: outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_selectability_cb); break; + case 6: outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_renderability_cb); break; + case 7: outliner_do_libdata_operation(C, scene, soops, &soops->tree, item_rename_cb); break; + default: + BLI_assert(0); + return OPERATOR_CANCELLED; } + + if (event == 3) { /* instance */ + Main *bmain = CTX_data_main(C); + + /* works without this except if you try render right after, see: 22027 */ + DAG_scene_sort(bmain, scene); + } - ED_undo_push(C, str); + ED_undo_push(C, prop_group_op_types[event].name); WM_event_add_notifier(C, NC_GROUP, NULL); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index cb8b309dc72..7edf18136d2 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -1658,7 +1658,7 @@ static void bone_matrix_translate_y(float mat[][4], float y) /* assumes object is Armature with pose */ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, const unsigned char ob_wire_col[4], - const short is_ghost, const short is_outline) + const short do_const_color, const short is_outline) { RegionView3D *rv3d = ar->regiondata; Object *ob = base->object; @@ -1753,8 +1753,13 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, if (bone == arm->act_bone) flag |= BONE_DRAW_ACTIVE; - /* set color-set to use */ - set_pchan_colorset(ob, pchan); + if (do_const_color) { + /* keep color */ + } + else { + /* set color-set to use */ + set_pchan_colorset(ob, pchan); + } if (use_custom) { /* if drawwire, don't try to draw in solid */ @@ -1828,10 +1833,10 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, } /* prepare colors */ - if (is_ghost) { + if (do_const_color) { /* 13 October 2009, Disabled this to make ghosting show the right colors (Aligorith) */ } - else if (arm->flag & ARM_POSEMODE) + else if (arm->flag & ARM_POSEMODE) set_pchan_colorset(ob, pchan); else { glColor3ubv(ob_wire_col); @@ -1950,7 +1955,12 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, /* extra draw service for pose mode */ /* set color-set to use */ - set_pchan_colorset(ob, pchan); + if (do_const_color) { + /* keep color */ + } + else { + set_pchan_colorset(ob, pchan); + } if ((pchan->custom) && !(arm->flag & ARM_NO_CUSTOM)) { /* custom bone shapes should not be drawn here! */ @@ -1985,20 +1995,35 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, glDisable(GL_CULL_FACE); /* draw DoFs */ - if (arm->flag & ARM_POSEMODE) - draw_pose_dofs(ob); + if (arm->flag & ARM_POSEMODE) { + if (((base->flag & OB_FROMDUPLI) == 0)) { + draw_pose_dofs(ob); + } + } /* finally names and axes */ - if ((arm->flag & (ARM_DRAWNAMES | ARM_DRAWAXES)) && (is_outline == 0)) { + if ((arm->flag & (ARM_DRAWNAMES | ARM_DRAWAXES)) && + (is_outline == 0) && + ((base->flag & OB_FROMDUPLI) == 0)) + { /* patch for several 3d cards (IBM mostly) that crash on GL_SELECT with text drawing */ if ((G.f & G_PICKSEL) == 0) { float vec[3]; - + unsigned char col[4]; - col[0] = ob_wire_col[0]; - col[1] = ob_wire_col[1]; - col[2] = ob_wire_col[2]; - col[3] = 255; + if (do_const_color) { + /* so we can draw bone names in current const color */ + float tcol[4]; + glGetFloatv(GL_CURRENT_COLOR, tcol); + rgb_float_to_uchar(col, tcol); + col[3] = 255; + } + else { + col[0] = ob_wire_col[0]; + col[1] = ob_wire_col[1]; + col[2] = ob_wire_col[2]; + col[3] = 255; + } if (v3d->zbuf) glDisable(GL_DEPTH_TEST); @@ -2546,11 +2571,8 @@ int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, if (dt > OB_WIRE && !ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)) { /* we use color for solid lighting */ - glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); - glEnable(GL_COLOR_MATERIAL); - glColor3ub(255, 255, 255); // clear spec - glDisable(GL_COLOR_MATERIAL); - + const float white[4] = {1.0f, 1.0f, 1.0f, 1.0f}; + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, white); glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); // only for lighting... } @@ -2602,7 +2624,7 @@ int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, } } } - draw_pose_bones(scene, v3d, ar, base, dt, ob_wire_col, FALSE, is_outline); + draw_pose_bones(scene, v3d, ar, base, dt, ob_wire_col, (flag & DRAW_CONSTCOLOR), is_outline); arm->flag &= ~ARM_POSEMODE; if (ob->mode & OB_MODE_POSE) diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index de1d9f22667..19696b2b0e0 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -1015,14 +1015,14 @@ void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *d if (ob && ob->mode & OB_MODE_WEIGHT_PAINT) { if (do_light) { + const float spec[4] = {0.47f, 0.47f, 0.47f, 0.47f}; + /* enforce default material settings */ GPU_enable_material(0, NULL); /* but set default spec */ glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); - glEnable(GL_COLOR_MATERIAL); /* according manpages needed */ - glColor3ub(120, 120, 120); - glDisable(GL_COLOR_MATERIAL); + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec); /* diffuse */ glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 63dc6c21863..63780ebbd20 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -1231,19 +1231,23 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, /* lamp center */ copy_v3_v3(vec, ob->obmat[3]); - - /* for AA effects */ - curcol[0] = ob_wire_col[0]; - curcol[1] = ob_wire_col[1]; - curcol[2] = ob_wire_col[2]; - curcol[3] = 154; - glColor4ubv(curcol); + + if ((flag & DRAW_CONSTCOLOR) == 0) { + /* for AA effects */ + curcol[0] = ob_wire_col[0]; + curcol[1] = ob_wire_col[1]; + curcol[2] = ob_wire_col[2]; + curcol[3] = 154; + glColor4ubv(curcol); + } if (lampsize > 0.0f) { - if (ob->id.us > 1) { - if (ob == OBACT || (ob->flag & SELECT)) glColor4ub(0x88, 0xFF, 0xFF, 155); - else glColor4ub(0x77, 0xCC, 0xCC, 155); + if ((flag & DRAW_CONSTCOLOR) == 0) { + if (ob->id.us > 1) { + if (ob == OBACT || (ob->flag & SELECT)) glColor4ub(0x88, 0xFF, 0xFF, 155); + else glColor4ub(0x77, 0xCC, 0xCC, 155); + } } /* Inner Circle */ @@ -1253,8 +1257,10 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, drawcircball(GL_POLYGON, vec, lampsize, imat); /* restore */ - if (ob->id.us > 1) - glColor4ubv(curcol); + if ((flag & DRAW_CONSTCOLOR) == 0) { + if (ob->id.us > 1) + glColor4ubv(curcol); + } /* Outer circle */ circrad = 3.0f * lampsize; @@ -1486,9 +1492,10 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, glDisable(GL_BLEND); - /* restore for drawing extra stuff */ - glColor3ubv(ob_wire_col); - + if ((flag & DRAW_CONSTCOLOR) == 0) { + /* restore for drawing extra stuff */ + glColor3ubv(ob_wire_col); + } } static void draw_limit_line(float sta, float end, unsigned int col) @@ -3427,6 +3434,8 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material); } else { + const float spec[4] = {0.47f, 0.47f, 0.47f, 0.47f}; + /* draw outline */ if ( (v3d->flag & V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) && @@ -3444,9 +3453,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D /* set default spec */ glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); - glEnable(GL_COLOR_MATERIAL); /* according manpages needed */ - glColor3ub(120, 120, 120); - glDisable(GL_COLOR_MATERIAL); + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec); /* diffuse */ glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); glEnable(GL_LIGHTING); @@ -6540,7 +6547,8 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) RegionView3D *rv3d = ar->regiondata; float vec1[3], vec2[3]; unsigned int col = 0; - unsigned char ob_wire_col[4]; + unsigned char _ob_wire_col[4]; /* dont initialize this */ + unsigned char *ob_wire_col = NULL; /* dont initialize this, use NULL crashes as a way to find invalid use */ int i, selstart, selend, empty_object = 0; short dt, dtx, zbufoff = 0; const short is_obact = (ob == OBACT); @@ -6578,9 +6586,6 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) /* no return after this point, otherwise leaks */ view3d_cached_text_draw_begin(); - /* patch? children objects with a timeoffs change the parents. How to solve! */ - /* if ( ((int)ob->ctime) != F_(scene->r.cfra)) BKE_object_where_is_calc(scene, ob); */ - /* draw motion paths (in view space) */ if (ob->mpath && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { bAnimVizSettings *avs = &ob->avs; @@ -6604,7 +6609,8 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) project_short(ar, ob->obmat[3], &base->sx); - draw_object_wire_color(scene, base, ob_wire_col, warning_recursive); + draw_object_wire_color(scene, base, _ob_wire_col, warning_recursive); + ob_wire_col = _ob_wire_col; glColor3ubv(ob_wire_col); } diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 7c12816741d..a36c14151e6 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1146,7 +1146,6 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) /* border */ if (scene->r.mode & R_BORDER) { - cpack(0); x3 = x1 + scene->r.border.xmin * (x2 - x1); y3 = y1 + scene->r.border.ymin * (y2 - y1); @@ -2735,12 +2734,15 @@ static void draw_viewport_fps(Scene *scene, ARegion *ar) BLF_draw_default_ascii(22, ar->winy - 17, 0.0f, printable, sizeof(printable)); } -static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar) +static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const char **grid_unit); + +static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw_border) { Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); RenderEngineType *type; + GLint scissor[4]; /* create render engine */ if (!rv3d->render_engine) { @@ -2757,17 +2759,48 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar) view3d_main_area_setup_view(scene, v3d, ar, NULL, NULL); /* background draw */ + ED_region_pixelspace(ar); + + if (draw_border) { + /* for border draw, we only need to clear a subset of the 3d view */ + rctf viewborder; + rcti cliprct; + + ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewborder, FALSE); + + cliprct.xmin = viewborder.xmin + scene->r.border.xmin * (viewborder.xmax - viewborder.xmin); + cliprct.ymin = viewborder.ymin + scene->r.border.ymin * (viewborder.ymax - viewborder.ymin); + cliprct.xmax = viewborder.xmin + scene->r.border.xmax * (viewborder.xmax - viewborder.xmin); + cliprct.ymax = viewborder.ymin + scene->r.border.ymax * (viewborder.ymax - viewborder.ymin); + + cliprct.xmin += ar->winrct.xmin; + cliprct.xmax += ar->winrct.xmin; + cliprct.ymin += ar->winrct.ymin; + cliprct.ymax += ar->winrct.ymin; + + cliprct.xmin = MAX2(cliprct.xmin, ar->winrct.xmin); + cliprct.ymin = MAX2(cliprct.ymin, ar->winrct.ymin); + cliprct.xmax = MIN2(cliprct.xmax, ar->winrct.xmax); + cliprct.ymax = MIN2(cliprct.ymax, ar->winrct.ymax); + + glGetIntegerv(GL_SCISSOR_BOX, scissor); + glScissor(cliprct.xmin, cliprct.ymin, cliprct.xmax - cliprct.xmin, cliprct.ymax - cliprct.ymin); + } + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - ED_region_pixelspace(ar); - - /* render result draw */ if (v3d->flag & V3D_DISPBGPICS) view3d_draw_bgpic(scene, ar, v3d, FALSE, TRUE); else fdrawcheckerboard(0, 0, ar->winx, ar->winy); + if (draw_border) { + /* restore scissor as it was before */ + glScissor(scissor[0], scissor[1], scissor[2], scissor[3]); + } + + /* render result draw */ type = rv3d->render_engine->type; type->view_draw(rv3d->render_engine, C); @@ -3028,15 +3061,21 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha void view3d_main_area_draw(const bContext *C, ARegion *ar) { + Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); const char *grid_unit = NULL; + int draw_border = (rv3d->persp == RV3D_CAMOB && (scene->r.mode & R_BORDER)); - /* draw viewport using external renderer? */ - if (!(v3d->drawtype == OB_RENDER && view3d_main_area_draw_engine(C, ar))) { - /* draw viewport using opengl */ + /* draw viewport using opengl */ + if (v3d->drawtype != OB_RENDER || draw_border) { view3d_main_area_draw_objects(C, ar, &grid_unit); ED_region_pixelspace(ar); } + + /* draw viewport using external renderer */ + if (v3d->drawtype == OB_RENDER) + view3d_main_area_draw_engine(C, ar, draw_border); view3d_main_area_draw_info(C, ar, grid_unit); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index c99c4b8a50c..fb28afbbdd9 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -5216,7 +5216,7 @@ void initEdgeSlide(TransInfo *t) int handleEventEdgeSlide(struct TransInfo *t, struct wmEvent *event) { - if (t->flag & TFM_EDGE_SLIDE) { + if (t->mode == TFM_EDGE_SLIDE) { SlideData *sld = t->customData; if (sld) { @@ -5258,7 +5258,7 @@ int handleEventEdgeSlide(struct TransInfo *t, struct wmEvent *event) void drawNonPropEdge(const struct bContext *C, TransInfo *t) { - if (t->flag & TFM_EDGE_SLIDE) { + if (t->mode == TFM_EDGE_SLIDE) { SlideData *sld = (SlideData *)t->customData; /* Non-Prop mode */ if (sld && sld->is_proportional == FALSE) { diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 2637d9e3b9b..38ac8c2999c 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -5878,7 +5878,7 @@ void flushTransTracking(TransInfo *t) /* * masking * */ -typedef struct TransDataMasking{ +typedef struct TransDataMasking { int is_handle; float handle[2], orig_handle[2]; diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 4ea89de9070..52b32ae66fc 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -51,8 +51,7 @@ #include "transform.h" -typedef struct TransformModeItem -{ +typedef struct TransformModeItem { char *idname; int mode; void (*opfunc)(wmOperatorType*); diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index b9bd7e961f8..fb248f1b016 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -1261,8 +1261,8 @@ void mtex_bump_bicubic( vec3 texco, sampler2D ima, float hScale, mat4 H; - for(int i = 0; i < 4; i++){ - for(int j = 0; j < 4; j++){ + for(int i = 0; i < 4; i++) { + for(int j = 0; j < 4; j++) { ivec2 iTexTmp = iTexLocMod + ivec2(i,j); // wrap texture coordinates manually for texelFetch to work on uvs oitside the 0,1 range. diff --git a/source/blender/ikplugin/CMakeLists.txt b/source/blender/ikplugin/CMakeLists.txt index 87b0c6c671a..f37b254d719 100644 --- a/source/blender/ikplugin/CMakeLists.txt +++ b/source/blender/ikplugin/CMakeLists.txt @@ -57,8 +57,5 @@ if(WITH_IK_ITASC) ) endif() -if(WIN32) - add_definitions(-DEIGEN_DONT_ALIGN_STATICALLY) -endif() blender_add_lib(bf_ikplugin "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/ikplugin/SConscript b/source/blender/ikplugin/SConscript index 4cff3399fdc..38c53894df8 100644 --- a/source/blender/ikplugin/SConscript +++ b/source/blender/ikplugin/SConscript @@ -8,7 +8,4 @@ incs += ' ../blenkernel ../include ../ikplugin #/intern/itasc #/extern/Eigen3' defs.append('WITH_IK_ITASC') -if env['PLATFORM'] == 'win32': - defs.append('EIGEN_DONT_ALIGN_STATICALLY') - env.BlenderLib ( 'bf_ikplugin', sources, Split(incs), defs, libtype=['core','player'], priority=[180, 190] ) diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp index ebbb201de8e..048dd955726 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cpp +++ b/source/blender/ikplugin/intern/itasc_plugin.cpp @@ -1000,7 +1000,7 @@ static void convert_pose(IK_Scene *ikscene) // assume uniform scaling and take Y scale as general scale for the armature scale = len_v3(ikscene->blArmature->obmat[1]); - rot = (ikscene->jointArray.rows() > 0) ? &ikscene->jointArray(0) : NULL; + rot = ikscene->jointArray(0); for (joint=a=0, ikchan = ikscene->channels; a<ikscene->numchan && joint<ikscene->numjoint; ++a, ++ikchan) { pchan= ikchan->pchan; bone= pchan->bone; @@ -1041,7 +1041,7 @@ static void BKE_pose_rest(IK_Scene *ikscene) // rest pose is 0 SetToZero(ikscene->jointArray); // except for transY joints - rot = (ikscene->jointArray.rows() > 0) ? &ikscene->jointArray(0) : NULL; + rot = ikscene->jointArray(0); for (joint=a=0, ikchan = ikscene->channels; a<ikscene->numchan && joint<ikscene->numjoint; ++a, ++ikchan) { pchan= ikchan->pchan; bone= pchan->bone; @@ -1140,7 +1140,7 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) // in Blender, the rest pose is always 0 for joints BKE_pose_rest(ikscene); } - rot = (ikscene->jointArray.rows() > 0) ? &ikscene->jointArray(0) : NULL; + rot = ikscene->jointArray(0); for (a=0, ikchan = ikscene->channels; a<tree->totchannel; ++a, ++ikchan) { pchan= ikchan->pchan; bone= pchan->bone; diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 93a5f8eca7c..baea18d4898 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -904,8 +904,7 @@ static ExrHandle *imb_exr_begin_read_mem(InputFile *file, int width, int height) /* ********************************************************* */ -typedef struct RGBA -{ +typedef struct RGBA { float r; float g; float b; diff --git a/source/blender/makesdna/DNA_actuator_types.h b/source/blender/makesdna/DNA_actuator_types.h index f4e06455c63..4a5ad69cb91 100644 --- a/source/blender/makesdna/DNA_actuator_types.h +++ b/source/blender/makesdna/DNA_actuator_types.h @@ -62,8 +62,7 @@ typedef struct bActionActuator { float layer_weight; /* How much of the previous layer to use for blending. (<0 = disable, 0 = add mode) */ } bActionActuator; -typedef struct Sound3D -{ +typedef struct Sound3D { float min_gain; float max_gain; float reference_distance; diff --git a/source/blender/makesdna/DNA_cloth_types.h b/source/blender/makesdna/DNA_cloth_types.h index b214186fee6..4928a88b33e 100644 --- a/source/blender/makesdna/DNA_cloth_types.h +++ b/source/blender/makesdna/DNA_cloth_types.h @@ -44,8 +44,7 @@ * variables with different names to minimize confusion. */ -typedef struct ClothSimSettings -{ +typedef struct ClothSimSettings { struct LinkNode *cache; /* UNUSED atm */ float mingoal; /* see SB */ float Cdis; /* Mechanical damping of springs. */ @@ -89,8 +88,7 @@ typedef struct ClothSimSettings } ClothSimSettings; -typedef struct ClothCollSettings -{ +typedef struct ClothCollSettings { struct LinkNode *collision_list; /* e.g. pointer to temp memory for collisions */ float epsilon; /* min distance for collisions. */ float self_friction; /* Fiction/damping with self contact. */ diff --git a/source/blender/makesdna/DNA_listBase.h b/source/blender/makesdna/DNA_listBase.h index 35549aee3d2..333e414278d 100644 --- a/source/blender/makesdna/DNA_listBase.h +++ b/source/blender/makesdna/DNA_listBase.h @@ -41,22 +41,19 @@ extern "C" { #endif /* generic - all structs which are used in linked-lists used this */ -typedef struct Link -{ +typedef struct Link { struct Link *next, *prev; } Link; /* use this when it is not worth defining a custom one... */ -typedef struct LinkData -{ +typedef struct LinkData { struct LinkData *next, *prev; void *data; } LinkData; /* never change the size of this! genfile.c detects pointerlen with it */ -typedef struct ListBase -{ +typedef struct ListBase { void *first, *last; } ListBase; diff --git a/source/blender/makesdna/DNA_mask_types.h b/source/blender/makesdna/DNA_mask_types.h index c036369c692..23f33729f69 100644 --- a/source/blender/makesdna/DNA_mask_types.h +++ b/source/blender/makesdna/DNA_mask_types.h @@ -43,9 +43,9 @@ typedef struct Mask { ID id; struct AnimData *adt; - ListBase masklayers; /* mask layers */ - int masklay_act; /* index of active mask layer (-1 == None) */ - int masklay_tot; /* total number of mask layers */ + ListBase masklayers; /* mask layers */ + int masklay_act; /* index of active mask layer (-1 == None) */ + int masklay_tot; /* total number of mask layers */ } Mask; typedef struct MaskParent { @@ -166,5 +166,4 @@ enum { MASK_BLENDFLAG_INVERT = (1 << 0) }; - #endif // __DNA_MASK_TYPES_H__ diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h index f5d525d47b5..0853df87a35 100644 --- a/source/blender/makesdna/DNA_particle_types.h +++ b/source/blender/makesdna/DNA_particle_types.h @@ -234,8 +234,8 @@ typedef struct ParticleSettings { struct PartDeflect *pd2; } ParticleSettings; -typedef struct ParticleSystem -{ /* note1: make sure all (runtime) are NULL's in 'copy_particlesystem' XXX, this function is no more! - need to invstigate */ +typedef struct ParticleSystem { + /* note1: make sure all (runtime) are NULL's in 'copy_particlesystem' XXX, this function is no more! - need to invstigate */ /* note2: make sure any uses of this struct in DNA are accounted for in 'BKE_object_copy_particlesystems' */ struct ParticleSystem *next, *prev; diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 0c88c7d9c81..73188b3f830 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -421,7 +421,7 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text, fclose(fp); - pystring = MEM_mallocN(strlen(fn) + 36, "pystring"); + pystring = MEM_mallocN(strlen(fn) + 37, "pystring"); pystring[0] = '\0'; sprintf(pystring, "f=open(r'%s');exec(f.read());f.close()", fn); py_result = PyRun_String(pystring, Py_file_input, py_dict, py_dict); diff --git a/source/blender/render/extern/include/RE_shader_ext.h b/source/blender/render/extern/include/RE_shader_ext.h index cf9e6f7966f..26a1b9908b3 100644 --- a/source/blender/render/extern/include/RE_shader_ext.h +++ b/source/blender/render/extern/include/RE_shader_ext.h @@ -45,8 +45,7 @@ typedef struct TexResult { } TexResult; /* localized shade result data */ -typedef struct ShadeResult -{ +typedef struct ShadeResult { float combined[4]; float col[4]; float alpha, mist, z; @@ -95,8 +94,7 @@ typedef struct ShadeInputCol { } ShadeInputCol; /* localized renderloop data */ -typedef struct ShadeInput -{ +typedef struct ShadeInput { /* copy from face, also to extract tria from quad */ /* note it mirrors a struct above for quick copy */ diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index f84b00451a6..e5af51cf2d7 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -65,16 +65,14 @@ struct Main; #define TABLEINITSIZE 1024 #define LAMPINITSIZE 256 -typedef struct SampleTables -{ +typedef struct SampleTables { float centLut[16]; float *fmask1[9], *fmask2[9]; char cmask[256], *centmask; } SampleTables; -typedef struct QMCSampler -{ +typedef struct QMCSampler { struct QMCSampler *next, *prev; int type; int tot; @@ -88,8 +86,7 @@ typedef struct QMCSampler #define SAMP_TYPE_HAMMERSLEY 2 /* this is handed over to threaded hiding/passes/shading engine */ -typedef struct RenderPart -{ +typedef struct RenderPart { struct RenderPart *next, *prev; RenderResult *result; /* result of part rendering */ @@ -347,8 +344,7 @@ typedef struct ObjectInstanceRen { /* ------------------------------------------------------------------------- */ -typedef struct VertRen -{ +typedef struct VertRen { float co[3]; float n[3]; float *orco; @@ -384,8 +380,7 @@ typedef struct VlakRen { int index; } VlakRen; -typedef struct HaloRen -{ +typedef struct HaloRen { short miny, maxy; float alfa, xs, ys, rad, radsq, sin, cos, co[3], no[3]; float hard, b, g, r; @@ -456,8 +451,7 @@ typedef struct StrandRen { /* ------------------------------------------------------------------------- */ -typedef struct VolumeOb -{ +typedef struct VolumeOb { struct VolumeOb *next, *prev; struct Material *ma; struct ObjectRen *obr; @@ -469,8 +463,7 @@ typedef struct MatInside { struct ObjectInstanceRen *obi; } MatInside; -typedef struct VolPrecachePart -{ +typedef struct VolPrecachePart { struct VolPrecachePart *next, *prev; struct RayObject *tree; struct ShadeInput *shi; @@ -486,8 +479,7 @@ typedef struct VolPrecachePart struct Render *re; } VolPrecachePart; -typedef struct VolumePrecache -{ +typedef struct VolumePrecache { int res[3]; float *bbmin, *bbmax; float *data_r; diff --git a/source/blender/render/intern/include/rendercore.h b/source/blender/render/intern/include/rendercore.h index 284b386ca33..0fbbf52e613 100644 --- a/source/blender/render/intern/include/rendercore.h +++ b/source/blender/render/intern/include/rendercore.h @@ -46,16 +46,14 @@ struct RayObject; /* ------------------------------------------------------------------------- */ -typedef struct PixStr -{ +typedef struct PixStr { struct PixStr *next; int obi, facenr, z, maskz; unsigned short mask; short shadfac; } PixStr; -typedef struct PixStrMain -{ +typedef struct PixStrMain { struct PixStrMain *next, *prev; struct PixStr *ps; int counter; diff --git a/source/blender/render/intern/include/sunsky.h b/source/blender/render/intern/include/sunsky.h index 0afd9246150..4bb7d99ba16 100644 --- a/source/blender/render/intern/include/sunsky.h +++ b/source/blender/render/intern/include/sunsky.h @@ -31,8 +31,7 @@ #define SPECTRUM_START 350.0 #define SPECTRUM_END 800.0 -typedef struct SunSky -{ +typedef struct SunSky { short effect_type, skyblendtype, sky_colorspace; float turbidity; float theta, phi; diff --git a/source/blender/render/intern/include/voxeldata.h b/source/blender/render/intern/include/voxeldata.h index 63620331c85..dd2262e0357 100644 --- a/source/blender/render/intern/include/voxeldata.h +++ b/source/blender/render/intern/include/voxeldata.h @@ -35,8 +35,7 @@ struct Render; struct TexResult; -typedef struct VoxelDataHeader -{ +typedef struct VoxelDataHeader { int resolX, resolY, resolZ; int frames; } VoxelDataHeader; diff --git a/source/blender/render/intern/include/zbuf.h b/source/blender/render/intern/include/zbuf.h index 77cee59a83a..cdf171443d7 100644 --- a/source/blender/render/intern/include/zbuf.h +++ b/source/blender/render/intern/include/zbuf.h @@ -80,8 +80,7 @@ typedef struct APixstrand { struct APixstrand *next; } APixstrand; -typedef struct APixstrMain -{ +typedef struct APixstrMain { struct APixstrMain *next, *prev; void *ps; } APixstrMain; diff --git a/source/blender/render/intern/raytrace/rayobject_instance.cpp b/source/blender/render/intern/raytrace/rayobject_instance.cpp index ce88bac1587..92a412103ba 100644 --- a/source/blender/render/intern/raytrace/rayobject_instance.cpp +++ b/source/blender/render/intern/raytrace/rayobject_instance.cpp @@ -62,8 +62,7 @@ static RayObjectAPI instance_api = RE_rayobject_instance_hint_bb }; -typedef struct InstanceRayObject -{ +typedef struct InstanceRayObject { RayObject rayobj; RayObject *target; diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index a2b911911d0..a48a6b75049 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -520,8 +520,7 @@ static void calc_tangent_vector(ObjectRen *obr, VertexTangent **vtangents, MemAr ************ tangent space generation interface **************** ****************************************************************/ -typedef struct -{ +typedef struct { ObjectRen *obr; } SRenderMeshToTangent; @@ -1011,8 +1010,7 @@ static Material *give_render_material(Render *re, Object *ob, short nr) /* ------------------------------------------------------------------------- */ /* Particles */ /* ------------------------------------------------------------------------- */ -typedef struct ParticleStrandData -{ +typedef struct ParticleStrandData { struct MCol *mcol; float *orco, *uvco, *surfnor; float time, adapt_angle, adapt_pix, size; diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index 96a1a13b75f..3c1a18316ca 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -325,8 +325,7 @@ void free_pointdensities(Render *re) } } -typedef struct PointDensityRangeData -{ +typedef struct PointDensityRangeData { float *density; float squared_radius; float *point_data; diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 25abc171057..a15d020c230 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -385,7 +385,7 @@ typedef struct wmTabletData { float Ytilt; /* as above */ } wmTabletData; -typedef enum { // motion progress, for modal handlers +typedef enum { /* motion progress, for modal handlers */ P_NOT_STARTED, P_STARTING, // <-- P_IN_PROGRESS, // <-- only these are sent for NDOF motion diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 7361e74755e..265a3c11377 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -577,12 +577,11 @@ int wm_window_fullscreen_toggle_exec(bContext *C, wmOperator *UNUSED(op)) /* ************ events *************** */ -typedef enum -{ - SHIFT = 's', - CONTROL = 'c', - ALT = 'a', - OS = 'C' +typedef enum { + SHIFT = 's', + CONTROL = 'c', + ALT = 'a', + OS = 'C' } modifierKeyType; /* check if specified modifier key type is pressed */ diff --git a/source/blenderplayer/CMakeLists.txt b/source/blenderplayer/CMakeLists.txt index 2ca7019487f..99db5576fa0 100644 --- a/source/blenderplayer/CMakeLists.txt +++ b/source/blenderplayer/CMakeLists.txt @@ -31,12 +31,6 @@ if(WITH_CODEC_QUICKTIME) add_definitions(-DWITH_QUICKTIME) endif() -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dna.c - COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/makesdna ${CMAKE_CURRENT_BINARY_DIR}/dna.c ${CMAKE_SOURCE_DIR}/source/blender/makesdna/ - DEPENDS ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/makesdna -) - if(WIN32 AND NOT UNIX) string(SUBSTRING ${BLENDER_VERSION} 0 1 bver1) string(SUBSTRING ${BLENDER_VERSION} 2 1 bver2) @@ -60,10 +54,10 @@ if(WIN32 AND NOT UNIX) ) endif() - add_executable(blenderplayer ${EXETYPE} ${CMAKE_CURRENT_BINARY_DIR}/dna.c ../icons/winblender.rc) + add_executable(blenderplayer ${EXETYPE} bad_level_call_stubs/stubs.c ../icons/winblender.rc) elseif(APPLE) - add_executable(blenderplayer ${EXETYPE} ${CMAKE_CURRENT_BINARY_DIR}/dna.c) + add_executable(blenderplayer ${EXETYPE} bad_level_call_stubs/stubs.c) # setup Info.plist execute_process(COMMAND date "+%Y-%m-%d" OUTPUT_VARIABLE BLENDER_DATE OUTPUT_STRIP_TRAILING_WHITESPACE) set(PLAYER_SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blenderplayer.app) @@ -74,7 +68,7 @@ elseif(APPLE) MACOSX_BUNDLE_LONG_VERSION_STRING "${BLENDER_VERSION} ${BLENDER_DATE}") else() - add_executable(blenderplayer ${CMAKE_CURRENT_BINARY_DIR}/dna.c) + add_executable(blenderplayer bad_level_call_stubs/stubs.c) endif() add_dependencies(blenderplayer makesdna) diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index f38782a9405..7174a563efa 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -529,7 +529,7 @@ bool BL_ArmatureObject::SetActiveAction(BL_ActionActuator *act, short priority, return true; } - else{ + else { act->SetBlendTime(0.0); return false; } diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 3d73ca66c92..927a0535870 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -488,11 +488,10 @@ static void GetRGB(short type, } } -typedef struct MTF_localLayer -{ +typedef struct MTF_localLayer { MTFace *face; const char *name; -}MTF_localLayer; +} MTF_localLayer; // ------------------------------------ bool ConvertMaterial( @@ -1193,7 +1192,7 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, KX_Scene* scene, twoside = ((ma->game.flag & GEMAT_BACKCULL)==0); collider = ((ma->game.flag & GEMAT_NOPHYSICS)==0); } - else{ + else { visible = true; twoside = false; collider = true; diff --git a/source/gameengine/Converter/BL_DeformableGameObject.cpp b/source/gameengine/Converter/BL_DeformableGameObject.cpp index dd4c51b5403..4967401f279 100644 --- a/source/gameengine/Converter/BL_DeformableGameObject.cpp +++ b/source/gameengine/Converter/BL_DeformableGameObject.cpp @@ -76,7 +76,7 @@ bool BL_DeformableGameObject::SetActiveAction(BL_ShapeActionActuator *act, short return true; } - else{ + else { act->SetBlendTime(0.0f); return false; } diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index 13e79b13304..c339e10f673 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -316,7 +316,7 @@ bool BL_ShapeActionActuator::Update(double curtime, bool frame) m_localtime += (length/m_stridelength) * deltapos.length(); m_lastpos = newpos; } - else{ + else { SetLocalTime(curtime); } } @@ -466,7 +466,7 @@ bool BL_ShapeActionActuator::Update(double curtime, bool frame) BLI_freelistN(&tchanbase); } } - else{ + else { m_blendframe = 0.0f; } } diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 0613b137fe8..78e5d7b32c2 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -930,13 +930,34 @@ bool KX_BlenderSceneConverter::LinkBlendFilePath(const char *path, char *group, return LinkBlendFile(bpy_openlib, path, group, scene_merge, err_str, options); } -bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options) +static void load_datablocks(Main *main_newlib, BlendHandle *bpy_openlib, const char *path, int idcode) { - Main *main_newlib; /* stored as a dynamic 'main' until we free it */ Main *main_tmp= NULL; /* created only for linking, then freed */ LinkNode *names = NULL; - int idcode= BKE_idcode_from_name(group); short flag= 0; /* don't need any special options */ + + /* here appending/linking starts */ + main_tmp = BLO_library_append_begin(main_newlib, &bpy_openlib, (char *)path); + + int totnames_dummy; + names = BLO_blendhandle_get_datablock_names( bpy_openlib, idcode, &totnames_dummy); + + int i=0; + LinkNode *n= names; + while(n) { + BLO_library_append_named_part(main_tmp, &bpy_openlib, (char *)n->link, idcode); + n= (LinkNode *)n->next; + i++; + } + BLI_linklist_free(names, free); /* free linklist *and* each node's data */ + + BLO_library_append_end(NULL, main_tmp, &bpy_openlib, idcode, flag); +} + +bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options) +{ + Main *main_newlib; /* stored as a dynamic 'main' until we free it */ + int idcode= BKE_idcode_from_name(group); ReportList reports; static char err_local[255]; @@ -964,40 +985,11 @@ bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const cha main_newlib= (Main *)MEM_callocN( sizeof(Main), "BgeMain"); BKE_reports_init(&reports, RPT_STORE); - /* here appending/linking starts */ - main_tmp = BLO_library_append_begin(main_newlib, &bpy_openlib, (char *)path); - - int totnames_dummy; - names = BLO_blendhandle_get_datablock_names( bpy_openlib, idcode, &totnames_dummy); - - int i=0; - LinkNode *n= names; - while(n) { - BLO_library_append_named_part(main_tmp, &bpy_openlib, (char *)n->link, idcode); - n= (LinkNode *)n->next; - i++; - } - BLI_linklist_free(names, free); /* free linklist *and* each node's data */ - - BLO_library_append_end(NULL, main_tmp, &bpy_openlib, idcode, flag); + load_datablocks(main_newlib, bpy_openlib, path, idcode); /* now do another round of linking for Scenes so all actions are properly loaded */ if (idcode==ID_SCE && options & LIB_LOAD_LOAD_ACTIONS) { - main_tmp = BLO_library_append_begin(main_newlib, &bpy_openlib, (char *)path); - - int totnames_dummy; - names = BLO_blendhandle_get_datablock_names( bpy_openlib, ID_AC, &totnames_dummy); - - int i=0; - LinkNode *n= names; - while(n) { - BLO_library_append_named_part(main_tmp, &bpy_openlib, (char *)n->link, ID_AC); - n= (LinkNode *)n->next; - i++; - } - BLI_linklist_free(names, free); /* free linklist *and* each node's data */ - - BLO_library_append_end(NULL, main_tmp, &bpy_openlib, ID_AC, flag); + load_datablocks(main_newlib, bpy_openlib, path, ID_AC); } BLO_blendhandle_close(bpy_openlib); diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index 278febee4ac..c50e42446a5 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -527,7 +527,7 @@ typedef struct KX_PYATTRIBUTE_DEF { /*------------------------------ * PyObjectPlus ------------------------------*/ -typedef PyTypeObject * PyParentObject; // Define the PyParent Object +typedef PyTypeObject *PyParentObject; /* Define the PyParent Object */ #else // WITH_PYTHON diff --git a/source/gameengine/Expressions/Value.h b/source/gameengine/Expressions/Value.h index 00320ff9ed2..261f5244f21 100644 --- a/source/gameengine/Expressions/Value.h +++ b/source/gameengine/Expressions/Value.h @@ -158,7 +158,7 @@ class CAction public: CAction() { }; - virtual ~CAction(){ + virtual ~CAction() { }; virtual void Execute() const =0; diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h index a6809716e32..685cc3fcc48 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h @@ -99,7 +99,7 @@ class SCA_Joystick void OnButtonDown(SDL_Event *sdl_event); void OnNothing(SDL_Event *sdl_event); #if 0 /* not used yet */ - void OnBallMotion(SDL_Event *sdl_event){} + void OnBallMotion(SDL_Event *sdl_event) {} #endif #endif /* WITH_SDL */ @@ -156,27 +156,27 @@ public: void cSetPrecision(int val); - int GetAxisPosition(int index){ + int GetAxisPosition(int index) { return m_axis_array[index]; } - int GetHat(int index){ + int GetHat(int index) { return m_hat_array[index]; } - int GetThreshold(void){ + int GetThreshold(void) { return m_prec; } - bool IsTrigAxis(void){ + bool IsTrigAxis(void) { return m_istrig_axis; } - bool IsTrigButton(void){ + bool IsTrigButton(void) { return m_istrig_button; } - bool IsTrigHat(void){ + bool IsTrigHat(void) { return m_istrig_hat; } diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 07fad3bfe37..c82e015919d 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -137,7 +137,8 @@ bool SCA_JoystickSensor::Evaluate() if (js->aAxisPairIsPositive(m_axis-1)) { /* use zero based axis index internally */ m_istrig = 1; result = true; - }else{ + } + else { if (m_istrig) { m_istrig = 0; result = true; @@ -148,7 +149,8 @@ bool SCA_JoystickSensor::Evaluate() if (js->aAxisPairDirectionIsPositive(m_axis-1, m_axisf)) { /* use zero based axis index internally */ m_istrig = 1; result = true; - }else{ + } + else { if (m_istrig) { m_istrig = 0; result = true; @@ -168,7 +170,8 @@ bool SCA_JoystickSensor::Evaluate() if (js->aAxisIsPositive(m_axis-1)) { /* use zero based axis index internally */ m_istrig = 1; result = true; - }else{ + } + else { if (m_istrig) { m_istrig = 0; result = true; @@ -209,7 +212,8 @@ bool SCA_JoystickSensor::Evaluate() if ((m_bAllEvents && js->GetHat(m_hat-1)) || js->aHatIsPositive(m_hat-1, m_hatf)) { m_istrig = 1; result = true; - }else{ + } + else { if (m_istrig) { m_istrig = 0; result = true; diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.h b/source/gameengine/GameLogic/SCA_JoystickSensor.h index eecbf2c4183..5dc35faf244 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.h +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.h @@ -117,7 +117,7 @@ public: virtual bool IsPositiveTrigger(); virtual void Init(); - short int GetJoyIndex(void){ + short int GetJoyIndex(void) { return m_joyindex; } diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 1e16cbd51f2..26cfc560b6d 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -118,8 +118,7 @@ static void mem_error_cb(const char *errorStr) } #ifdef WIN32 -typedef enum -{ +typedef enum { SCREEN_SAVER_MODE_NONE = 0, SCREEN_SAVER_MODE_PREVIEW, SCREEN_SAVER_MODE_SAVER, diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.h b/source/gameengine/Ketsji/KX_BulletPhysicsController.h index 4ced21aa2d8..3b3a1f5cbfb 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.h +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.h @@ -86,7 +86,7 @@ public: SetOption( int option, int value - ){ + ) { // intentionally empty }; diff --git a/source/gameengine/Ketsji/KX_Dome.cpp b/source/gameengine/Ketsji/KX_Dome.cpp index eaabbdd8233..6d57b6950f1 100644 --- a/source/gameengine/Ketsji/KX_Dome.cpp +++ b/source/gameengine/Ketsji/KX_Dome.cpp @@ -445,7 +445,8 @@ void KX_Dome::GLDrawWarpQuads(void) } } glEnd(); - } else{ + } + else { printf("Dome Error: Warp Mode %d unsupported. Try 1 for Polar Mesh or 2 for Fisheye.\n", warp.mode); } } @@ -502,7 +503,8 @@ bool KX_Dome::ParseWarpMesh(STR_String text) if ((int)lines.size() < 2 + (warp.n_width * warp.n_height)) { printf("Dome Error: Warp Mesh File with insufficient data!\n"); return false; - }else{ + } + else { warp.nodes = vector<vector<WarpMeshNode> > (warp.n_height, vector<WarpMeshNode>(warp.n_width)); for (i=2; i-2 < (warp.n_width*warp.n_height); i++) { @@ -520,7 +522,7 @@ bool KX_Dome::ParseWarpMesh(STR_String text) warp.nodes[nodeY][nodeX].v = atof(columns[3]); warp.nodes[nodeY][nodeX].i = atof(columns[4]); } - else{ + else { warp.nodes.clear(); printf("Dome Error: Warp Mesh File with wrong number of fields. You should use 5: x y u v i.\n"); return false; @@ -1671,7 +1673,8 @@ void KX_Dome::DrawEnvMap(void) if (can_width/3 <= can_height/2) { ortho_width = 1.0; ortho_height = (float)can_height/can_width; - }else{ + } + else { ortho_height = 2.0f / 3; ortho_width = (float)can_width/can_height * ortho_height; } @@ -1801,7 +1804,8 @@ void KX_Dome::DrawDomeFisheye(void) if (can_width < can_height) { ortho_width = 1.0; ortho_height = (float)can_height/can_width; - }else{ + } + else { ortho_width = (float)can_width/can_height; ortho_height = 1.0; } @@ -1897,7 +1901,8 @@ void KX_Dome::DrawPanorama(void) if ((can_width / 2) <= (can_height)) { ortho_width = 1.0; ortho_height = (float)can_height/can_width; - }else{ + } + else { ortho_width = (float)can_width/can_height * 0.5; ortho_height = 0.5; } @@ -1995,7 +2000,7 @@ void KX_Dome::DrawDomeWarped(void) glBindTexture(GL_TEXTURE_2D, domefacesId[m_numfaces]); glCallList(dlistId + m_numfaces); } - else{ + else { glBindTexture(GL_TEXTURE_2D, domefacesId[m_numfaces]); GLDrawWarpQuads(); } diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index a173ef1ed8f..2b0d13ff2f7 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -712,7 +712,7 @@ public: void AddMesh( RAS_MeshObject* mesh - ){ + ) { m_meshes.push_back(mesh); } diff --git a/source/gameengine/Ketsji/KX_IpoActuator.cpp b/source/gameengine/Ketsji/KX_IpoActuator.cpp index 9777eaf333e..7e7e7f8cef2 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.cpp +++ b/source/gameengine/Ketsji/KX_IpoActuator.cpp @@ -297,7 +297,7 @@ bool KX_IpoActuator::Update(double curtime, bool frame) { SetLocalTime(curtime); } - else{ + else { if (!m_bNegativeEvent) { /* Perform wraparound */ SetLocalTime(curtime); diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index 0a50ab0a43a..f9c6d59b668 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -150,8 +150,7 @@ private: int m_curreye; /** Categories for profiling display. */ - typedef enum - { + typedef enum { tc_first = 0, tc_physics = 0, tc_logic, diff --git a/source/gameengine/Ketsji/KX_LightIpoSGController.h b/source/gameengine/Ketsji/KX_LightIpoSGController.h index 78466e822e7..15591bfa981 100644 --- a/source/gameengine/Ketsji/KX_LightIpoSGController.h +++ b/source/gameengine/Ketsji/KX_LightIpoSGController.h @@ -90,7 +90,7 @@ public: SetOption( int option, int value - ){ + ) { // intentionally empty }; diff --git a/source/gameengine/Ketsji/KX_MaterialIpoController.h b/source/gameengine/Ketsji/KX_MaterialIpoController.h index 85b2a971fbe..11d92925a02 100644 --- a/source/gameengine/Ketsji/KX_MaterialIpoController.h +++ b/source/gameengine/Ketsji/KX_MaterialIpoController.h @@ -49,7 +49,7 @@ public: SetOption( int option, int value - ){ + ) { // intentionally empty }; diff --git a/source/gameengine/Ketsji/KX_ObColorIpoSGController.h b/source/gameengine/Ketsji/KX_ObColorIpoSGController.h index d2d69d6db12..d2f4c69bf47 100644 --- a/source/gameengine/Ketsji/KX_ObColorIpoSGController.h +++ b/source/gameengine/Ketsji/KX_ObColorIpoSGController.h @@ -64,7 +64,7 @@ public: SetOption( int option, int value - ){ + ) { // intentionally empty }; diff --git a/source/gameengine/Ketsji/KX_SoundActuator.h b/source/gameengine/Ketsji/KX_SoundActuator.h index 71ec3ae2f59..dbdb17d0da5 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.h +++ b/source/gameengine/Ketsji/KX_SoundActuator.h @@ -43,8 +43,7 @@ #include "BKE_sound.h" -typedef struct KX_3DSoundSettings -{ +typedef struct KX_3DSoundSettings { float min_gain; float max_gain; float reference_distance; diff --git a/source/gameengine/Ketsji/KX_WorldIpoController.h b/source/gameengine/Ketsji/KX_WorldIpoController.h index 1f60280e355..9578130b51e 100644 --- a/source/gameengine/Ketsji/KX_WorldIpoController.h +++ b/source/gameengine/Ketsji/KX_WorldIpoController.h @@ -88,7 +88,7 @@ public: SetOption( int option, int value - ){ + ) { // intentionally empty }; diff --git a/source/gameengine/Rasterizer/RAS_LightObject.h b/source/gameengine/Rasterizer/RAS_LightObject.h index c378a9ea0c2..ddf360683cd 100644 --- a/source/gameengine/Rasterizer/RAS_LightObject.h +++ b/source/gameengine/Rasterizer/RAS_LightObject.h @@ -36,7 +36,7 @@ struct RAS_LightObject { - enum LightType{ + enum LightType { LIGHT_SPOT, LIGHT_SUN, LIGHT_NORMAL diff --git a/source/gameengine/SceneGraph/SG_ParentRelation.h b/source/gameengine/SceneGraph/SG_ParentRelation.h index 689ada84edd..4140563828f 100644 --- a/source/gameengine/SceneGraph/SG_ParentRelation.h +++ b/source/gameengine/SceneGraph/SG_ParentRelation.h @@ -76,8 +76,7 @@ public : virtual ~SG_ParentRelation( - ){ - }; + ) {}; /** * You must provide a way of duplicating an |