Skip to content

Commit 2da9738

Browse files
authored
Merge pull request #6 from XiaoFFGe/blender-v4.5-release
Blender v4.5 release
2 parents 8b4747f + af019f5 commit 2da9738

7 files changed

Lines changed: 45 additions & 6 deletions

File tree

locale/po/zh_HANS.po

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ msgid "Collision Mask"
145145
msgstr "碰撞遮罩"
146146

147147

148+
msgid "Change the speed of the simulation for this rigid body"
149+
msgstr "更改此刚体的模拟速度"
150+
151+
148152
msgctxt "Operator"
149153
msgid "Selected Build Collision Mask"
150154
msgstr "从选择构建遮罩"

scripts/startup/bl_operators/rigidbody.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,6 @@ def execute(self, context):
350350
return {'FINISHED'}
351351

352352
# 从选择构建遮罩
353-
354-
355353
class BuildCollisionMaskFromRigidBody(Operator):
356354
"""Selected Build collision mask from rigid body"""
357355
bl_idname = "rigidbody.build_collision_mask"

scripts/startup/bl_ui/properties_physics_rigidbody.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,14 +374,16 @@ def draw(self, context):
374374
# col = layout.column(align=True)
375375
# col.label(text="Activation:")
376376
# XXX: settings such as activate on collision/etc.
377+
378+
col = flow.column()
379+
col.prop(rbo, "time_scale", text="Time Scale")
377380

378381
col = flow.column()
379382
col.prop(rbo, "linear_damping", text="Damping Translation")
380383

381384
col = flow.column()
382385
col.prop(rbo, "angular_damping", text="Rotation")
383386

384-
385387
class PHYSICS_PT_rigid_body_dynamics_deactivation(PHYSICS_PT_rigidbody_panel, Panel):
386388
bl_label = "Deactivation"
387389
bl_parent_id = "PHYSICS_PT_rigid_body_dynamics"

source/blender/blenkernel/BKE_blender_version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
/** Blender major and minor version. */
2020
#define BLENDER_VERSION 405
2121
/** Blender patch version for bug-fix releases. */
22-
#define BLENDER_VERSION_PATCH 10
22+
#define BLENDER_VERSION_PATCH 11
2323
/** Blender release cycle stage: alpha/beta/rc/release. */
2424
#define BLENDER_VERSION_CYCLE release
2525
/** Blender release type suffix. LTS or blank. */
2626
#define BLENDER_VERSION_SUFFIX release
2727

2828
/* Blender file format version. */
2929
#define BLENDER_FILE_VERSION BLENDER_VERSION
30-
#define BLENDER_FILE_SUBVERSION 102
30+
#define BLENDER_FILE_SUBVERSION 110
3131

3232
/* Minimum Blender version that supports reading file written with the current
3333
* version. Older Blender versions will test this and cancel loading the file, showing a warning to

source/blender/blenkernel/intern/rigidbody.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,7 @@ RigidBodyOb *BKE_rigidbody_create_object(Scene *scene, Object *ob, short type)
12591259
/* set default settings */
12601260
rbo->type = type;
12611261

1262+
rbo->time_scale = 1.0f;
12621263
rbo->mass = 1.0f;
12631264

12641265
rbo->friction = 0.5f; /* best when non-zero. 0.5 is Bullet default */
@@ -2096,6 +2097,22 @@ static void rigidbody_update_simulation_post_step(Depsgraph *depsgraph, RigidBod
20962097
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (rbw->group, ob) {
20972098
Base *base = BKE_view_layer_base_find(view_layer, ob);
20982099
RigidBodyOb *rbo = ob->rigidbody_object;
2100+
2101+
/* Apply per-rigidbody time scale for active objects. */
2102+
if (rbo && rbo->type == RBO_TYPE_ACTIVE && rbo->shared->physics_object &&
2103+
!compare_ff(rbo->time_scale, 1.0f, FLT_EPSILON))
2104+
{
2105+
float lin_vel[3], ang_vel[3];
2106+
RB_body_get_linear_velocity(static_cast<rbRigidBody *>(rbo->shared->physics_object), lin_vel);
2107+
RB_body_get_angular_velocity(static_cast<rbRigidBody *>(rbo->shared->physics_object), ang_vel);
2108+
2109+
mul_v3_fl(lin_vel, rbo->time_scale);
2110+
mul_v3_fl(ang_vel, rbo->time_scale);
2111+
2112+
RB_body_set_linear_velocity(static_cast<rbRigidBody *>(rbo->shared->physics_object), lin_vel);
2113+
RB_body_set_angular_velocity(static_cast<rbRigidBody *>(rbo->shared->physics_object), ang_vel);
2114+
}
2115+
20992116
/* Reset kinematic state for transformed objects. */
21002117
if (rbo && base && (base->flag & BASE_SELECTED) && (G.moving & G_TRANSFORM_OBJ) &&
21012118
rbo->shared->physics_object)

source/blender/makesdna/DNA_rigidbody_types.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ typedef struct RigidBodyOb {
143143
struct ListBase xf_no_collision_objects;
144144

145145
/* Physics Parameters */
146+
/** Used to speed up or slow down the simulation for this rigid body. */
147+
float time_scale;
146148
/** How much object 'weighs' (i.e. absolute 'amount of stuff' it holds). */
147149
float mass;
148150

@@ -170,7 +172,7 @@ typedef struct RigidBodyOb {
170172
float pos[3];
171173
char _pad1[4];
172174

173-
char _pad2[16]; /* 为将来使用保留的填充字节 */
175+
char _pad2[12]; /* 为将来使用保留的填充字节 */
174176

175177
/** This pointer is shared between all evaluated copies. */
176178
struct RigidBodyOb_Shared *shared;

source/blender/makesrna/intern/rna_rigidbody.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,13 @@ static void rna_RigidBodyOb_disabled_set(PointerRNA *ptr, bool value)
363363
# endif
364364
}
365365

366+
static void rna_RigidBodyOb_time_scale_set(PointerRNA *ptr, float value)
367+
{
368+
RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
369+
370+
rbo->time_scale = value;
371+
}
372+
366373
static void rna_RigidBodyOb_mass_set(PointerRNA *ptr, float value)
367374
{
368375
RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
@@ -1192,6 +1199,15 @@ static void rna_def_rigidbody_object(BlenderRNA *brna)
11921199
RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
11931200

11941201
/* Physics Parameters */
1202+
prop = RNA_def_property(srna, "time_scale", PROP_FLOAT, PROP_NONE);
1203+
RNA_def_property_float_sdna(prop, nullptr, "time_scale");
1204+
RNA_def_property_range(prop, 0.0f, 100.0f);
1205+
RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
1206+
RNA_def_property_float_default(prop, 1.0f);
1207+
RNA_def_property_float_funcs(prop, nullptr, "rna_RigidBodyOb_time_scale_set", nullptr);
1208+
RNA_def_property_ui_text(prop, "Time Scale", "Change the speed of the simulation for this rigid body");
1209+
RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
1210+
11951211
prop = RNA_def_property(srna, "mass", PROP_FLOAT, PROP_UNIT_MASS);
11961212
RNA_def_property_float_sdna(prop, nullptr, "mass");
11971213
RNA_def_property_range(prop, 0.001f, FLT_MAX); /* range must always be positive (and non-zero) */

0 commit comments

Comments
 (0)