Skip to content

Commit 3203b14

Browse files
committed
refactoring
1 parent 1b47a10 commit 3203b14

File tree

4 files changed

+30
-36
lines changed

4 files changed

+30
-36
lines changed

Plugin/abci/Importer/aiCamera.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ aiCameraSample::aiCameraSample(aiCamera *schema)
1313

1414
void aiCameraSample::getData(aiCameraData &dst) const
1515
{
16-
dst = m_data;
16+
dst = data;
1717
}
1818

1919

@@ -31,53 +31,53 @@ void aiCamera::readSampleBody(Sample& sample, uint64_t idx)
3131
{
3232
auto ss = aiIndexToSampleSelector(idx);
3333
auto ss2 = aiIndexToSampleSelector(idx + 1);
34-
readVisibility(sample, ss);
3534

36-
m_schema.get(sample.m_sample, ss);
37-
m_schema.get(sample.m_next_sample, ss2);
35+
readVisibility(sample, ss);
36+
m_schema.get(sample.cam_sp, ss);
37+
m_schema.get(sample.cam_sp2, ss2);
3838
}
3939

4040
void aiCamera::cookSampleBody(Sample& sample)
4141
{
4242
auto& config = getConfig();
43-
auto& cs = sample.m_sample;
44-
auto& cs_next = sample.m_next_sample;
45-
auto& dst = sample.m_data;
43+
auto& sp = sample.cam_sp;
44+
auto& dst = sample.data;
4645

4746
dst.visibility = sample.visibility;
4847

4948
// Note: CameraSample::getFieldOfView() returns the horizontal field of view, we need the verical one
5049
static float sRad2Deg = 180.0f / float(M_PI);
51-
float focal_length = (float)cs.getFocalLength();
52-
float vertical_aperture = (float)cs.getVerticalAperture();
50+
float focal_length = (float)sp.getFocalLength();
51+
float vertical_aperture = (float)sp.getVerticalAperture();
5352
if (config.aspect_ratio > 0.0f)
54-
vertical_aperture = (float)cs.getHorizontalAperture() / config.aspect_ratio;
53+
vertical_aperture = (float)sp.getHorizontalAperture() / config.aspect_ratio;
5554

56-
dst.near_clipping_plane = (float)cs.getNearClippingPlane();
57-
dst.far_clipping_plane = (float)cs.getFarClippingPlane();
55+
dst.near_clipping_plane = (float)sp.getNearClippingPlane();
56+
dst.far_clipping_plane = (float)sp.getFarClippingPlane();
5857
dst.field_of_view = 2.0f * atanf(vertical_aperture * 10.0f / (2.0f * focal_length)) * sRad2Deg;
5958

60-
dst.focus_distance = (float)cs.getFocusDistance();
59+
dst.focus_distance = (float)sp.getFocusDistance();
6160
dst.focal_length = focal_length;
6261
dst.aperture = vertical_aperture;
63-
dst.aspect_ratio = float(cs.getHorizontalAperture() / vertical_aperture);
62+
dst.aspect_ratio = float(sp.getHorizontalAperture() / vertical_aperture);
6463

6564
if (config.interpolate_samples && m_current_time_offset != 0) {
65+
auto& sp2 = sample.cam_sp2;
6666
float time_offset = (float)m_current_time_offset;
67-
float focal_length2 = (float)cs_next.getFocalLength();
68-
float vertical_aperture2 = (float)cs_next.getVerticalAperture();
67+
float focal_length2 = (float)sp2.getFocalLength();
68+
float vertical_aperture2 = (float)sp2.getVerticalAperture();
6969
if (config.aspect_ratio > 0.0f)
70-
vertical_aperture2 = (float)cs_next.getHorizontalAperture() / config.aspect_ratio;
70+
vertical_aperture2 = (float)sp2.getHorizontalAperture() / config.aspect_ratio;
7171

7272
float fov2 = 2.0f * atanf(vertical_aperture2 * 10.0f / (2.0f * focal_length2)) * sRad2Deg;
73-
dst.near_clipping_plane += time_offset * (float)(cs_next.getNearClippingPlane() - cs.getNearClippingPlane());
74-
dst.far_clipping_plane += time_offset * (float)(cs_next.getFarClippingPlane() - cs.getFarClippingPlane());
73+
dst.near_clipping_plane += time_offset * (float)(sp2.getNearClippingPlane() - sp.getNearClippingPlane());
74+
dst.far_clipping_plane += time_offset * (float)(sp2.getFarClippingPlane() - sp.getFarClippingPlane());
7575
dst.field_of_view += time_offset * (fov2 - dst.field_of_view);
7676

77-
dst.focus_distance += time_offset * (float)(cs_next.getFocusDistance() - cs.getFocusDistance());
77+
dst.focus_distance += time_offset * (float)(sp2.getFocusDistance() - sp.getFocusDistance());
7878
dst.focal_length += time_offset * (focal_length2 - focal_length);
7979
dst.aperture += time_offset * (vertical_aperture2 - vertical_aperture);
80-
dst.aspect_ratio += time_offset * (float(cs_next.getHorizontalAperture() / vertical_aperture2) - dst.aspect_ratio);
80+
dst.aspect_ratio += time_offset * (float(sp2.getHorizontalAperture() / vertical_aperture2) - dst.aspect_ratio);
8181
}
8282

8383
if (dst.near_clipping_plane == 0.0f)

Plugin/abci/Importer/aiCamera.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ using super = aiSample;
99
void getData(aiCameraData &dst) const;
1010

1111
public:
12-
AbcGeom::CameraSample m_sample, m_next_sample;
13-
aiCameraData m_data;
12+
AbcGeom::CameraSample cam_sp, cam_sp2;
13+
aiCameraData data;
1414
};
1515

1616

Plugin/abci/Importer/aiXForm.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88

99
aiXformSample::aiXformSample(aiXform *schema)
10-
: super(schema), inherits(true)
10+
: super(schema)
1111
{
1212
}
1313

1414
void aiXformSample::getData(aiXformData &dst) const
1515
{
16-
dst = m_data;
16+
dst = data;
1717
}
1818

1919

@@ -41,22 +41,18 @@ void aiXform::cookSampleBody(Sample& sample)
4141
{
4242
auto& config = getConfig();
4343

44-
sample.inherits = sample.xf_sp.getInheritsXforms();
45-
sample.m_matrix = sample.xf_sp.getMatrix();
46-
sample.m_next_matrix = sample.xf_sp2.getMatrix();
47-
4844
Imath::V3d scale;
4945
Imath::V3d shear;
5046
Imath::Quatd rot;
5147
Imath::V3d trans;
52-
decompose(sample.m_matrix, scale, shear, rot, trans);
48+
decompose(sample.xf_sp.getMatrix(), scale, shear, rot, trans);
5349

5450
if (config.interpolate_samples && m_current_time_offset != 0)
5551
{
5652
Imath::V3d scale2;
5753
Imath::Quatd rot2;
5854
Imath::V3d trans2;
59-
decompose(sample.m_next_matrix, scale2, shear, rot2, trans2);
55+
decompose(sample.xf_sp2.getMatrix(), scale2, shear, rot2, trans2);
6056
scale += (scale2 - scale)* m_current_time_offset;
6157
trans += (trans2 - trans)* m_current_time_offset;
6258
rot = Imath::slerpShortestArc(rot, rot2, (double)m_current_time_offset);
@@ -75,9 +71,9 @@ void aiXform::cookSampleBody(Sample& sample)
7571
rot_final.x = -rot_final.x;
7672
rot_final.w = -rot_final.w;
7773
}
78-
auto& dst = sample.m_data;
74+
auto& dst = sample.data;
7975
dst.visibility = sample.visibility;
80-
dst.inherits = sample.inherits;
76+
dst.inherits = sample.xf_sp.getInheritsXforms();
8177
dst.translation = trans;
8278
dst.rotation = rot_final;
8379
dst.scale = scale;

Plugin/abci/Importer/aiXForm.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ using super = aiSample;
1010

1111
public:
1212
AbcGeom::XformSample xf_sp, xf_sp2;
13-
AbcGeom::M44d m_matrix, m_next_matrix;
14-
bool inherits;
15-
aiXformData m_data;
13+
aiXformData data;
1614
};
1715

1816

0 commit comments

Comments
 (0)